Random number / random-number-1-10
Random number 1-10
A ten-sided die, without the die.
- Sourcecrypto.getRandomValues()
- Entropy—
- draws105
Range preset to 1-10: fast choices, turns, scores. Every value has an exact 10% chance, visible in the histogram after a few hundred draws.
A naive generator computes random() % n. If the generator emits 2^32 values and n is not an exact divisor, some results appear more often: that is modulo bias, measurable and exploitable. Here we use rejection sampling: draw a 32-bit integer and discard it until it falls inside the largest exact multiple of n. Residual bias is exactly zero.
Ranges are normalized before drawing, and very wide ranges are composed from two words so the value stays inside JavaScript exact 53-bit integers: no precision loss, no silent rounding.
How it works
- 01Set minimum and maximum. Reversed values are reordered, decimals rejected.
- 02Choose how many numbers to draw and whether they must be unique: drawing is without replacement.
- 03Every click updates the session histogram, which is how uniformity becomes visible.
Frequently asked
Random number generator
Why not Math.random()?
Because it is deterministic and unfit for anything involving security or verifiable draws. V8 seeds it with a reconstructible state; crypto.getRandomValues() reads the OS entropy pool.
What is the maximum range?
Up to 2^53 distinct values, about nine quadrillion. Beyond that floating point precision is not guaranteed, and the tool says so instead of returning wrong values.
Can I reproduce the same sequence with a seed?
No, by design: there is no settable seed. For reproducible simulations you need a seeded PRNG, not a CSPRNG.