๐ฒ Random Number Generator
Generate random numbers quickly and easily. Set your range, choose how many, and get instant results. Ideal for games, lotteries, and research.
What is a random number generator?
A random number generator (RNG) is a tool that produces numbers without any discernible pattern or predictability. Whether you need to pick numbers for the National Lottery, randomise the order of a classroom activity, or conduct a research study, our free online generator delivers results in seconds. Simply set your minimum and maximum values, choose how many numbers you need, and decide whether to allow duplicate entries.
Random numbers are woven into the fabric of modern life. From the National Lottery draws broadcast on television to the cryptographic protocols that protect your online banking, RNGs work tirelessly behind the scenes to ensure fairness, security, and unpredictability.
Pseudo-random vs truly random numbers
There is an important distinction between pseudo-random number generators (PRNGs) and true random number generators (TRNGs). Understanding this difference helps you choose the right tool for your needs.
PRNGs use mathematical algorithms to produce sequences of numbers that appear random. They start from an initial value called a “seed” and apply a deterministic formula repeatedly. Modern browsers implement Math.random() using algorithms such as xoshiro128, which produce billions of numbers before the sequence repeats. Our generator uses this approach, and the results pass all standard statistical randomness tests.
TRNGs generate numbers based on genuinely unpredictable physical phenomena: thermal noise in electronic circuits, radioactive decay, or atmospheric disturbances. The most famous British TRNG is ERNIE (Electronic Random Number Indicator Equipment), which has been generating Premium Bonds winning numbers since 1957. Now in its fifth generation, ERNIE uses thermal noise in transistors to produce numbers that no algorithm could predict.
ERNIE and Premium Bonds: Britain's favourite RNG
Perhaps no random number generator is more beloved in Britain than ERNIE, the machine that selects winners for NS&I Premium Bonds. Created by Tommy Flowers' team at the Post Office Research Station in Dollis Hill, the original ERNIE was built in 1957 using technology derived from the Colossus computers that broke German codes at Bletchley Park during the Second World War.
ERNIE generates random numbers to select which Premium Bonds win prizes each month. With over £120 billion invested in Premium Bonds by millions of Britons, the fairness and randomness of the selection process is paramount. Each bond has an equal chance of winning, and the process is independently verified by the Government Actuary's Department.
The current ERNIE 5, introduced in 2019, can generate random numbers at a rate that would have astonished its creators. What once took days now takes hours, allowing NS&I to draw millions of prizes each month.
Practical applications of random numbers
Random numbers serve a remarkable variety of purposes across British life and beyond:
- The National Lottery: Lotto, EuroMillions, Thunderball, and Set For Life all depend on random selection. While the main draws use certified mechanical ball machines, our generator is perfect for choosing your own numbers or running informal sweepstakes at the office.
- Randomised controlled trials: The UK has a proud tradition of pioneering medical research, and randomised controlled trials (RCTs) are the gold standard. Sir Austin Bradford Hill introduced the randomised clinical trial in 1948 with the landmark streptomycin tuberculosis study. Today, NHS-funded research routinely uses random assignment to eliminate bias in clinical trials.
- ONS surveys and polling: The Office for National Statistics uses random sampling to select households for surveys including the Labour Force Survey and the Census follow-up studies. Random selection ensures that survey results are representative of the entire UK population.
- Cryptography and GCHQ: The Government Communications Headquarters in Cheltenham is at the forefront of cryptographic research. Secure random number generation is fundamental to the encryption that protects government communications, military operations, and the nation's critical infrastructure.
- Gaming and entertainment: From pub quiz tiebreakers to board game alternatives, our generator provides fair results. Tabletop gaming groups across Britain use digital dice rollers as a convenient alternative to physical dice.
- Education: Teachers use random number generators to call on students, assign groups, create randomised quiz questions, and demonstrate probability concepts in maths lessons.
Random sampling in UK research
Random sampling is the cornerstone of rigorous research methodology, and British institutions have been at the forefront of developing these techniques. Sir Ronald Fisher, working at Rothamsted Experimental Station in Hertfordshire in the 1920s and 1930s, laid the foundations of modern experimental design, including the principle of randomisation.
Today, UK universities, the NHS, and government bodies routinely use random sampling in their research. The UK Biobank, one of the world's largest biomedical databases, recruited approximately 500,000 participants selected through a partly randomised process. Public Health England (now the UK Health Security Agency) uses random sampling for disease surveillance programmes.
For academic research, random number generators serve multiple purposes: selecting participants from a sampling frame, randomly assigning participants to experimental conditions, determining the order of stimulus presentation, and randomising survey question order to minimise order effects.
How does our generator work?
Our random number generator uses the browser's built-in Math.random() function, which produces floating-point numbers between 0 and 1 with a uniform distribution. This means every value in the range is equally likely. We convert these into integers within your specified range using the standard formula: Math.floor(Math.random() × (max − min + 1)) + min.
When you disable duplicates, the generator employs the Fisher-Yates shuffle algorithm, a well-established method for producing unbiased random permutations. It creates a pool of all numbers in the range, shuffles them thoroughly, and then selects the first n elements. This guarantees that every possible combination of unique numbers is equally probable.
UK gambling regulation and random numbers
The UK Gambling Commission is one of the world's most rigorous regulators of gambling technology. All random number generators used in licensed gambling in Britain must be tested and certified by approved testing houses such as NMi, GLI, or BMM Testlabs. These laboratories verify that the RNG produces unbiased, unpredictable results across millions of test cycles.
The Commission's Remote Technical Standards require that RNGs used in online gambling must be cryptographically secure, independently audited, and continuously monitored. This ensures that every spin of a virtual roulette wheel, every deal of digital cards, and every scratch card reveal is genuinely random and fair to the player.
The mathematics of randomness
From a mathematical perspective, a uniform distribution means that each outcome in the sample space has an equal probability. For our generator with a range of 1 to n, each number has a probability of exactly 1/n. Over many draws, the frequency of each number converges towards this theoretical probability — a consequence of the Law of Large Numbers, first proved by Jacob Bernoulli in 1713.
This property makes the uniform distribution ideal for situations requiring fairness: lotteries, random selection, and unbiased sampling. Other distributions (normal, exponential, Poisson) serve different purposes in statistics and modelling but are less suitable for general-purpose random number generation.
Tips for using our generator
- For the National Lottery: Set the range to 1–59 for Lotto main numbers or 1–50 for EuroMillions main numbers. Generate the required quantity with duplicates disabled.
- For Premium Bond-style draws: Enter the total number of entries as the maximum value and generate one number to select the winner.
- For classroom use: Set the range from 1 to the number of pupils and generate one number at a time for fair, unbiased selection.
- For research sampling: Generate a list of numbers corresponding to participant IDs in your sampling frame. Use the “no duplicates” option to ensure unique selections.
- For board games: Replace physical dice by setting the range to 1–6 for a standard die or 1–12 for two dice. Allow duplicates for multiple independent rolls.
Randomness in British culture and tradition
Randomness has deep roots in British culture beyond the well-known Premium Bonds and National Lottery. The tradition of drawing lots has been part of English common law for centuries. Jury selection, one of the cornerstones of the British justice system, relies on random selection from the electoral register to ensure that juries are representative and impartial. Every year, millions of potential jurors across England and Wales are randomly selected for jury service at Crown Courts.
In sport, randomised draws determine fixtures, seedings, and match-ups across football, cricket, rugby, and tennis. The FA Cup draw, broadcast live and watched by millions, uses a simple random ball selection system that has produced some of the most memorable upsets in English football history. The randomness of the draw is what gives smaller clubs the chance to face Premier League giants, embodying the romance of the competition.
Cryptographic randomness and British innovation
Britain has a storied history in the intersection of randomness and cryptography. During the Second World War, the team at Bletchley Park — including Alan Turing, Gordon Welchman, and others — developed methods to exploit weaknesses in the German Enigma machine's pseudo-random rotor settings. The Colossus computers built by Tommy Flowers were among the world's first electronic computers, designed specifically to find patterns in seemingly random enciphered messages.
Today, GCHQ in Cheltenham continues this tradition as one of the world's leading signals intelligence organisations. The National Cyber Security Centre, a part of GCHQ, publishes guidance on cryptographic standards including requirements for random number generation in government systems. The British Standards Institution (BSI) maintains standards for random and pseudo-random number generators used in security applications.
In the commercial sector, British fintech companies use cryptographically secure random number generators to protect online transactions, generate unique session tokens, and create secure one-time passwords. The financial services sector in the City of London processes trillions of pounds in transactions annually, all protected by encryption that depends fundamentally on high-quality randomness.
Random number generators in education
British schools and universities make extensive use of random number generators in teaching. The national curriculum for mathematics at Key Stage 3 and 4 includes probability and statistics, where students learn about random events, sample spaces, and expected frequencies. Teachers use random number generators to create practical demonstrations: generating hundreds of dice rolls in seconds and comparing observed frequencies with theoretical probabilities teaches students about the Law of Large Numbers far more effectively than manual dice rolling.
At A-level and university, students encounter random number generation in the context of simulation, hypothesis testing, and confidence intervals. Computer science students study the algorithms behind PRNGs, their period lengths, and the mathematical properties that distinguish a good generator from a poor one. The Fisher-Yates shuffle algorithm used in our generator for duplicate-free selection is a classic teaching example of an efficient, unbiased randomisation method.