CSPRNG Randomness & Elimination of Modulo Bias
In computer science and statistical modeling, generating fair random numbers across non-power-of-two ranges (such as a 6-sided or 20-sided die) introduces a well-documented vulnerability known as modulo bias. When a raw pseudo-random 32-bit unsigned integer (0 to 232 - 1 = 4,294,967,295) is naively reduced via the modulo operator (X mod N), certain face outcomes occur with slightly higher frequency because 232 is not evenly divisible by N.
To achieve uncompromising cryptographic fairness, this simulator implements rejection sampling:
Any random integer generated by crypto.getRandomValues() that equals or exceeds this threshold is rejected and re-sampled. This guarantees uniform probability down to the exact mathematical limit.
Tabletop RPG Dice Symbology & Probability Profiles
| Die Type | Polyhedron Geometry | Discrete Uniform Probability | Primary TTRPG Mechanic (e.g. D&D 5e) |
|---|---|---|---|
| D4 | Regular Tetrahedron (4 faces) | 25.00% per face | Dagger damage, Magic Missile, Healing Word |
| D6 | Regular Hexahedron / Cube (6 faces) | 16.67% per face | Shortsword damage, Fireball damage, Rogue Sneak Attack |
| D8 | Regular Octahedron (8 faces) | 12.50% per face | Longsword damage, Cure Wounds, Cleric hit dice |
| D10 | Pentagonal Trapezohedron (10 faces) | 10.00% per face | Heavy crossbow, Halberd, Fighter hit dice |
| D12 | Regular Dodecahedron (12 faces) | 8.33% per face | Greataxe damage, Barbarian hit dice |
| D20 | Regular Icosahedron (20 faces) | 5.00% per face | Core D20 System: Attack rolls, ability checks, saving throws |
| D100 | Zocchihedron / 2d10 Percentile | 1.00% per integer | Wild Magic Surge table, Divine Intervention, Call of Cthulhu |
Bernoulli Trials & The Law of Large Numbers
The flip of an unbiased coin is the archetypal Bernoulli trial: an experiment with exactly two mutually exclusive outcomes (Success p = 0.5, Failure q = 1 - p = 0.5). While short runs frequently exhibit localized clustering (e.g. four heads in five flips), the Strong Law of Large Numbers proves that as the sample size n → ∞, the sample mean X̄n converges almost surely to the expected value μ = 0.5.