Behind the Spin: How Digital Random Wheels Generate Provably Fair Results
Explore pseudo-random number generators (PRNG), modulo arithmetic, friction curves, and client-side entropy in digital wheels.
Interactive Companion: Spin our free random wheel to test this setup with complete client-side randomness and zero account requirements.
Why Standard Math.random() Is Not Enough for Fair Draws
Many casual web spinners rely on Math.random() paired with simple rounding (Math.floor(Math.random() * n)). While fast for visual demos, naive modulo operations across non-power-of-two ranges introduce slight modulo bias—meaning earlier slices can become marginally more probable over thousands of spins.
How Cryptographic Rejection Sampling Guarantees Exact Uniformity
Every spin on our random wheel uses the browser's hardware-backed window.crypto.getRandomValues() API (a 32-bit unsigned integer pool) combined with rejection sampling:
- Compute a Divisible Cutoff: Calculate
limit = Math.floor(0x100000000 / n) * nso the accepted range divides evenly by the number of choicesn. - Reject Out-of-Range Samples: Draw a 32-bit random integer; if it exceeds
limit, discard it and re-sample before computingrand % n. - Separate Selection from Animation Physics: Once the winning slice is selected mathematically, the HTML5 Canvas animates 5 to 8 full rotations with a smooth quintic ease-out curve (
1 - (1 - t)5) so the wheel slows naturally onto that exact wedge without altering odds.
Zero-Bias Entropy Pipeline: Hardware entropy, Web Crypto sampling, and quintic ease-out animation work together right inside your browser—you can also verify 10,000 simulated spins live on our PRNG Audit Tool.
Why Client-Side Execution Matters
Because all draws execute inside local browser memory (or on our roulette wheel simulator), there is zero network latency and zero server-side log exposure of participant names.