Home › Guides › Random Numbers

How Random Number Generators Work

Last updated: September 2026 · Independently QA-tested formulas

Quick answer: A random number generator picks a number where every value in your range is equally likely. Online tools use a seeded pseudo-random algorithm — unpredictable in practice for games, draws and picks, though not cryptographic-grade.

Give me a number between 1 and 10, right now. Whatever you said, you didn't pick randomly — humans avoid round numbers, favor 7, and lean on recent memories. Computers are different: they produce sequences that pass statistical tests for randomness, which is exactly what a random number generator does for picks, draws, dice and raffles.

What is a random number generator?

An RNG is a procedure that outputs values with no usable pattern. Two families exist:

For picking a raffle winner or rolling a d20, a PRNG is exactly as fair as a physical die — arguably fairer, since a worn die is biased.

How a range pick works: the formula

value = min + floor(rand() × (max − min + 1))

Where rand() returns a uniform decimal in [0, 1). Multiplying stretches it across your range, flooring snaps it to whole numbers. Three properties matter:

Worked example: rand() returns 0.2719, range 1–100 → 1 + floor(0.2719 × 100) = 28.

What is a seed?

The seed is the PRNG's starting state. Same seed in, same sequence out — that's how scientists re-run identical simulations. Everyday tools seed from the system clock or OS entropy, so you never see repeats of the same sequence. If a tool lets you set a seed, use it only when you want reproducibility.

Can numbers repeat?

Yes — and they should. Independent draws mean yesterday's result has zero effect on today's. In a 1–10 range, a repeat appears within about 7 picks on average. That feels "unrandom" to humans (the gambler's fallacy) but is mathematically correct. Tools labeled "unique picks" or "no repeats" instead sample without replacement, like dealing cards.

Common uses and how to set them up

Common uses and how to set them up
Use caseSetup
Raffle / giveaway winnerNumber each entrant, generate one value from 1 to N
Dice replacementMin 1, max = sides; one draw per die
Lottery-style pickUse no-repeat mode with your game's range
Prize draw with 3 winnersGenerate 3 unique values from 1 to N (or re-roll duplicates)
Sampling for a surveyNumber the population, draw k unique values

Uniform vs weighted: when equal odds are the wrong answer

Every tool on this page is a uniform generator: each number in the range has exactly the same chance. That is what raffles and dice need — but not everything. Some real picks are weighted:

Randomness myths that cost people money

A security boundary you should know

PRNGs like Math.random() are ideal for dice, raffles and games — unpredictable enough that nobody can guess your next roll in practice. They are not designed to resist a determined attacker choosing passwords. Password generation needs a cryptographically secure source (CSPRNG), which is why our password generator exists separately from this one. The password entropy guide explains the math of why a 16-character passphrase beats an 8-character string of symbols.

The 2d6 curve: why some dice totals are rarer than others

One honest limitation of "pick a number from 1 to 36" for dice replacement: it gives a flat distribution, while real two-dice throws are peaked. Every one of the 36 (die, die) combinations is equally likely, but a total of 7 has six of them (1+6, 2+5, 3+4, 4+3, 5+2, 6+1) while 2 or 12 have one each:

The 2d6 curve: why some dice totals are rarer than others
Total23456789101112
Ways out of 3612345654321

So 7 comes up about 16.7% of the time — six times as often as snake eyes. Board games that "feel wrong" are usually just revealing this curve. For a dice game where the shape of the distribution matters, roll two dice separately (the dice roller does independent draws) rather than one uniform pick from the summed range.

Unique picks: how the odds actually change

Drawing with replacement keeps every draw at the same odds; drawing without replacement shifts them as the pool shrinks. A 6/49 lottery is the classic case: the first ball is a 1-in-49 shot, but the jackpot needs all six — 49 × 48 × 47 × 46 × 45 × 44 ÷ 720 orders = 1 in 13,983,816. That's C(49,6) — combinations, not permutations, because draw order doesn't matter.

The same combinatorics runs a raffle fairly: 150 unique picks from 200 entrants leaves the last entrant facing odds that rose from 1/200 toward 1/51 as others were drawn. Not unfair — just not the constant 1/200 your intuition keeps quoting. When fairness must be visible, publish the method: numbered entrants, unique-mode draw, order ignored.

Worked example: Coin Flip Simulator at its default inputs

This is the answer Coin Flip Simulator gives before you touch anything — the defaults as shipped, computed live rather than copied from a sample.

Default inputs
InputDefault
Number of Flips100

Result: Heads: 48 | Tails: 52

The steps behind that answer

  1. Each flip is an independent 50/50 trial
  2. With 100 flips expect ~50 heads
  3. Results vary — that is randomness

Number of Flips — three values, three answers

The table below varies number of flips alone — half, the default, and half again.

Number of Flips — three values, three answers
Number of FlipsResult
50Heads: 20 | Tails: 30
100Heads: 56 | Tails: 44
150Heads: 81 | Tails: 69

Read the three rows as a range: the spread between them is how much the answer depends on number of flips alone, with everything else held still.

Related guides

Not every random number is safe to use

A general-purpose generator such as Math.random is fine for a raffle or a dice roll and unsuitable for passwords, tokens or anything an attacker can profit from guessing. Cryptographic generators are slower precisely because they resist prediction.

The distinction is predictability, not appearance. A sequence can look random to a human and be fully determined by a seed an attacker can recover.

Watch the range mapping

Taking a raw random integer modulo a range introduces bias whenever the range does not divide the generator space evenly — the low values come up slightly more often. Rejection sampling avoids it.

The bias is tiny for a game and meaningful for a lottery-sized draw. If the fairness of the draw matters, use a generator that handles the mapping for you.

Seeds, reproducibility and streaks

A seeded generator replays the same sequence every time, which is what makes simulations testable. An unseeded one gives a different run each time, which is what makes shuffles fair.

Long streaks are not evidence of a broken generator. In a thousand coin flips, runs of six or seven in a row are ordinary — the intuition that they should not happen is the thing that is wrong.

Frequently Asked Questions

Is a 50/50 coin flip really 50/50?

A simulated coin flip is — each draw is uniform. Physical flips are slightly biased toward the side that starts facing up, research suggests around 50.8% for a standard flip.

Can I predict the next number?

Not without knowing the internal seed and state. For our tools' purposes (picks, dice, draws), the sequence is unpredictable.

Why do my dice rolls never total the average?

Average results are typical, not guaranteed. Three d6s average 10.5, but any total from 3–18 is possible; extremes are simply rarer. Try the dice roller and watch the spread over many rolls.

Is randomness fair for giveaways?

Yes, provided every entrant maps to exactly one number and the range covers all of them — the team randomizer handles the grouping for you.

Try the calculators

← All guides · Glossary · Methodology

Last updated