Random Number Generator
Generate one or many random integers within a custom range using cryptographically secure randomness. View statistical summaries of your generated set including mean, median, and distribution.
What Makes a Number Genuinely Random?
Randomness sounds simple until you try to pin down what it actually means. Most people think of it as unpredictability — you can't guess what comes next. Mathematicians take it further and define a truly random sequence as one with no compressible structure, meaning there's no shortcut to describe it other than writing out every single element. That's a surprisingly high bar, and it has practical implications for how computers generate random numbers.
Here's the fundamental problem: computers are deterministic machines. Every operation follows rigid logic, which means a standard algorithm can't produce genuine randomness out of thin air. What it can do is gather entropy — messy, unpredictable physical data — from the hardware. Things like electrical noise on a circuit board, microscopic timing variations between keystrokes, temperature fluctuations in the CPU sensor, and even mouse movement patterns all contribute tiny bits of genuine unpredictability.
The Web Crypto API that this generator relies on taps into those operating system entropy sources. On Windows machines, it's backed by CryptGenRandom, which harvests hardware noise. Linux systems use /dev/urandom with interrupt timing and device noise. macOS runs the Yarrow algorithm. The upshot is that the numbers you get here pass every standard statistical test for randomness — no patterns, no bias, no correlation between consecutive values.
For day-to-day purposes like picking raffle winners, choosing which restaurant to try, or assigning lab partners in a classroom, this is more randomness than you'll ever need. The numbers have no memory of what came before and no tendency toward any particular part of the range.
Pseudo-Random vs Cryptographically Secure vs True Random
Not all random number generators are created equal, and the differences matter more than you might think. At the bottom tier sits the basic pseudo-random number generator, or PRNG. JavaScript's Math.random() is a PRNG — it uses a mathematical formula (typically xorshift128+) and an initial seed to spit out a sequence that looks random but is completely deterministic. Give it the same seed twice and you'll get the exact same sequence. That's actually useful for things like video game replays or reproducible simulations, but it's terrible for anything security-related because someone who figures out the internal state can predict every future output.
Cryptographically secure pseudo-random number generators, or CSPRNGs, sit a tier higher. They still use algorithms, but they continuously mix in real entropy from hardware and are designed so that seeing past outputs tells you nothing about future ones. The crypto.getRandomValues() function in your browser falls into this camp. Breaking it would require solving mathematical problems that the entire cryptography community considers computationally infeasible with current technology.
At the top sit true random number generators, or TRNGs. These rely entirely on physical processes that are random according to the laws of physics: radioactive decay, photon beam splitting, quantum vacuum fluctuations, thermal noise in resistors. The Australian National University runs a quantum random number generator that measures vacuum fluctuations to produce numbers that are genuinely, physically unpredictable. Organizations like national intelligence agencies and certificate authorities use TRNGs when the stakes are highest.
For this calculator, the CSPRNG in your browser provides randomness that is, for all practical purposes, indistinguishable from a TRNG. The theoretical gap between them matters to quantum physicists and cryptographic researchers, but for generating lottery picks, running classroom experiments, or creating random assignments, it makes zero practical difference.
Where Random Numbers Show Up in the Real World
You'd be surprised how much of modern life depends on random number generation happening reliably behind the scenes. Every time you load a webpage over HTTPS, a random nonce kicks off the TLS handshake that encrypts your connection. Every RSA encryption key starts with randomly chosen large prime numbers. If an attacker could predict those random values, the entire security infrastructure of the internet would crumble overnight — strong algorithms can't compensate for weak randomness.
Statistical sampling is another massive consumer. When a polling firm surveys 1,500 people to estimate how 200 million voters feel about an issue, the credibility of those results depends entirely on the randomness of the sample selection. Biased sampling produces biased conclusions, no matter how large your sample gets. Medical clinical trials use random assignment to treatment and control groups for the same reason — it's the only way to ensure the groups are comparable and that observed effects are genuinely caused by the treatment rather than by pre-existing differences between participants.
Monte Carlo simulations consume random numbers by the billions. Engineers estimating the failure probability of a bridge under extreme weather run millions of simulated storms with randomly varied wind speeds, rain intensities, and load conditions. Financial analysts model portfolio risk by simulating thousands of possible market scenarios. Climate scientists project temperature trends by running models with randomly perturbed initial conditions. In every case, the quality of the randomness directly affects the reliability of the results.
Even machine learning leans on randomness at multiple points: random initialization of neural network weights, random shuffling of training data between epochs, dropout regularization that randomly silences neurons during training, and stochastic gradient descent itself, which uses randomly selected mini-batches. Without good randomness, training would be slower, less stable, and more prone to getting stuck in poor solutions.
Probability Basics: What to Expect from Your Random Numbers
When you generate a random number between 1 and 100, each integer has exactly a 1% chance of appearing. That's what mathematicians call a uniform distribution — every outcome is equally likely. It's the simplest probability distribution and the one most people intuitively expect from anything labeled "random."
Things get more nuanced when you generate multiple numbers. With duplicates allowed, each draw is independent. The probability of getting any specific sequence — say 42, then 17, then 83 — is (1/100)³ = one in a million. The total number of possible three-number sequences from a range of 100 is 100³ = 1,000,000.
Without duplicates, the math shifts. You're now sampling without replacement: the first pick has 100 options, the second has 99, the third has 98. That's a permutation, and the formula is P(100, 3) = 100 × 99 × 98 = 970,200 possible ordered sequences. If order doesn't matter — you just care about which three numbers were picked — you use the combination formula C(100, 3) = 161,700.
This distinction comes up in real situations more than you'd think. Lottery drawings are combinations: order doesn't matter, duplicates aren't allowed. Rolling dice is sampling with replacement since each roll is independent. Drawing cards from a deck is sampling without replacement. Knowing which model applies to your problem determines whether you should check or uncheck the duplicates option in this generator.
One thing worth knowing: the expected mean of numbers drawn uniformly between min and max is (min + max) / 2. For the range 1 to 100, that's 50.5. If you generate 1,000 numbers, their average will land very close to 50.5 — not exactly, but close. The more numbers you generate, the tighter the observed average clusters around that theoretical expectation. That's the law of large numbers at work, and it's one of the most reliable phenomena in all of probability.
Uniform Random Integer Generation
P(x) = 1 / (max - min + 1) for each integer x in [min, max]
Each integer in the specified range has an equal probability of being selected. The probability of any single value is 1 divided by the total count of integers in the range. For a range of 1 to 100, each number has a 1/100 or 1% chance of being picked on any given draw. When generating without duplicates, the process is equivalent to a random permutation of the range followed by taking the first N elements. This generator uses crypto.getRandomValues() to produce unbiased uniform random integers by rejection sampling within the range.
Where:
- P(x) = Probability of selecting any specific integer x from the range
- min = Lower bound of the range (inclusive)
- max = Upper bound of the range (inclusive)
Example Calculations
Single Random Number 1-100
Generating a single random number within the classic 1 to 100 range.
With a range of 1 to 100 and a quantity of 1, the generator selects one integer uniformly at random from the 100 possible values. Each number has an equal 1% chance of being selected. The output is a single value — in this example, 47.
Lottery-Style Pick (6 Unique from 1-49)
Generating 6 non-repeating numbers for a lottery-style selection.
Selecting 6 unique integers from 1 to 49 mimics a common lottery format. With duplicates disabled, each number can only appear once. There are C(49,6) = 13,983,816 possible combinations, meaning any specific set of 6 numbers has roughly a 1 in 14 million chance of being drawn.
Frequently Asked Questions
This generator uses crypto.getRandomValues(), a cryptographically secure pseudo-random number generator built into your browser. It draws entropy from hardware sources through the operating system. While technically pseudo-random (produced by an algorithm), its output passes all standard statistical randomness tests and is computationally indistinguishable from true randomness. For all practical purposes including simulations, games, sampling, and selection tasks, these numbers are as random as you need.
Yes. Set the Allow Duplicates option to No, and the generator will ensure every number in the result is unique. This is equivalent to drawing from a pool without replacement. Note that the quantity cannot exceed the size of the range when duplicates are disabled. For example, you cannot generate 200 unique numbers from a range of 1 to 100 because only 100 distinct values exist in that range.
You can generate up to 100 numbers in a single batch. This limit keeps the browser responsive and the output readable. For most applications — lottery picks, random assignments, simulation seeds, game setups — a hundred values is more than enough. If you need larger datasets for statistical work, consider using a dedicated tool like R, Python's random module, or a command-line CSPRNG utility.
If you enter a minimum value greater than the maximum, the generator will swap them automatically so that the range is valid. Internally the calculation always needs min to be less than or equal to max. The tool handles this silently rather than displaying an error, so you do not need to worry about entering them in the wrong order.
You can use it to generate random numbers in whatever range your lottery requires, and with duplicates disabled the results will mimic a fair lottery draw. However, keep in mind that lotteries are games of pure chance. No generator, method, or strategy can improve your odds of winning. The probability of any specific combination being drawn is identical regardless of how the numbers were chosen. Using a random generator simply removes human bias from your number selection, which is neither an advantage nor a disadvantage statistically.