RNG Audit: What Testing Can and Cannot Prove

How pseudo-random number generators are seeded, scaled and statistically tested, what a certification covers, and why no audit can predict an individual outcome.

Updated Reading time 10 min By Editorial Team

What the RNG does in a game

Every game of chance delivered by software reduces to one question: where does the unpredictability come from, and is it distributed the way the rules say?

The random number generator (RNG) is the component that answers the first half. It produces a stream of numbers that the game logic then maps onto reel positions, card draws, dice faces or a point on a crash curve. Everything downstream — paytable, bonus features, displayed result — is deterministic once the number is fixed. So an audit of fairness starts by asking whether the stream is unpredictable, uniformly distributed over the range the game needs, and free of dependence between successive draws.

PRNG, hardware entropy and CSPRNG

Almost all gaming RNGs are pseudo-random number generators (PRNGs): deterministic algorithms that expand a short secret starting value, the seed, into a very long sequence whose statistical properties resemble true randomness. Given the same seed, a PRNG produces the same sequence. That is a feature for testing and a hazard for security, which is why the seed must be secret and derived from genuine entropy.

Hardware or “true” random number generators (TRNGs) sample a physical process — electronic noise, oscillator jitter, quantum effects — to produce bits that are not reproducible. In practice they are used as an entropy source to seed and periodically re-seed a PRNG rather than to drive the game directly, because raw physical output is slow and may carry bias that must be conditioned away.

A cryptographically secure PRNG (CSPRNG) is a PRNG designed so that observing part of its output gives no computational advantage in predicting the rest, and so that recovering the internal state from output is infeasible. NIST’s deterministic random bit generator constructions (Hash_DRBG, HMAC_DRBG, CTR_DRBG) in SP 800-90A are the reference designs. Older general-purpose generators such as the Mersenne Twister have excellent statistical behaviour but are not designed to resist state recovery, which is why modern gaming standards expect a cryptographic construction or an equivalent justification.

Seeds and entropy

The seed is the only part of a PRNG that carries real unpredictability. Three properties are examined in an audit:

  • Entropy of the source. How many bits of genuine unpredictability does the source deliver per sample? SP 800-90B describes how entropy sources are assessed and health-tested.
  • Seed length and freshness. A seed must be long enough that exhaustive search is infeasible, and the generator must re-seed on a defined schedule so that a long-running process does not expose a single state indefinitely.
  • Isolation. Seed material must not be derivable from observable quantities such as the clock, a session identifier or a player action. Weak seeding — not weak algorithms — has been the root cause of most historical RNG failures.

Scope note

This page explains why seeding requirements exist. It does not describe methods for recovering state or seeds from observed output, and no page on this site will.

From raw bits to an outcome: scaling

A generator emits numbers in a fixed range — commonly 32 or 64 bits. A game needs a number in a small range: 1 to 37 for a roulette wheel, 0 to 99 for a percentage, a reel position from 1 to 128. The step that converts one to the other is scaling, and it is the single most common place for bias to enter an otherwise sound system.

Take a 32-bit output and reduce it with a remainder operation to the range 0–36. There are 232 = 4,294,967,296 possible inputs and 37 outputs. Because 4,294,967,296 is not a multiple of 37, some outputs receive one more input than others: 232 mod 37 = 7, so the outputs 0 through 6 each occur 116,080,198 times while the remaining 30 occur 116,080,197 times. The bias here is tiny — about one part in 108 — but for smaller word sizes or larger ranges it is not, and standards therefore require either rejection sampling (discard inputs above the largest multiple of the range) or a documented argument that the residual bias is immaterial for the game.

An audit checks the scaling method explicitly. A perfect generator behind a careless scaling step is not a fair game.

Pipeline diagram

RNG pipeline from entropy to displayed result, with the verification activity applied at each stage Six stages flow top to bottom: entropy source and seed, random number generator, outcome selection by scaling, game logic, displayed result. A sixth stage, testing and verification, is shown as a column to the right listing what is examined at each stage: entropy assessment, statistical test suites and algorithm review, scaling bias check, paytable and functional testing, display accuracy and audit trail. STAGE 1 · ENTROPY SOURCE Physical noise → conditioned → seed material STAGE 2 · RNG (CSPRNG / DRBG) Seed expanded into 32/64-bit output stream STAGE 3 · OUTCOME SELECTION Scaling to game range (rejection sampling) STAGE 4 · GAME LOGIC Reel strips, paytable, features applied STAGE 5 · DISPLAYED RESULT Shown to player; logged to audit trail STAGE 6 · TESTING & VERIFICATION Applied across the pipeline, not at one point Entropy assessment Source health tests · SP 800-90B Algorithm review + statistical suites SP 800-22 · Dieharder · TestU01 · re-seed schedule Scaling bias check Chi-square on game-range outputs Paytable & functional testing Expected value · simulation · rule conformance Display accuracy & audit trail GOLD = ENTROPY · CYAN = DETERMINISTIC STAGES · GREEN = OUTPUT · DASHED = VERIFICATION SCOPE
Figure 1. The RNG pipeline. Unpredictability enters once, at stage 1; everything after it is deterministic and therefore testable. Verification activity (right) attaches to specific stages — which is why “the RNG is certified” needs to be read with the question “which stages?”

Statistical testing

Statistical testing asks whether a sample of generator output is consistent with the hypothesis that it came from a uniform, independent source. Three published suites dominate laboratory practice:

  • NIST SP 800-22 — fifteen tests on binary sequences, including frequency (monobit), block frequency, runs, longest run of ones, binary matrix rank, discrete Fourier transform, template matching, Maurer’s universal statistic, linear complexity, serial, approximate entropy, cumulative sums and random excursions.
  • Dieharder — a maintained successor to Marsaglia’s Diehard battery, adding tests and a consistent p-value framework.
  • TestU01 — L’Ecuyer and Simard’s library with the SmallCrush, Crush and BigCrush batteries; BigCrush runs over 150 statistics and is the most demanding commonly cited battery.

For the scaled outputs a game actually uses, the workhorse is the chi-square goodness-of-fit test: count how often each outcome appears over a large sample, compare with the expected count, and compute whether the discrepancy is larger than chance would produce. Serial and gap tests probe dependence between successive outcomes.

How to read the results

Each test produces a p-value: the probability of seeing a discrepancy at least this large if the generator were perfect. A p-value below a chosen threshold (0.01 and 0.001 are common) is a failure for that test on that sample. Two consequences follow that are often missed:

  • A perfect generator should fail roughly 1% of tests at the 0.01 level. One isolated failure in a battery of hundreds is expected; a pattern of failures on the same statistic across independent samples is the signal.
  • Passing every test does not prove randomness. It proves the absence of the specific regularities the tests look for, in the sample tested. This is why algorithm review and seeding review accompany statistical testing rather than being replaced by it.

What RNG certification covers

A laboratory RNG certificate typically records that a named implementation — algorithm, source code or binary identified by hash, seeding mechanism, scaling routines — was reviewed against a named standard and passed specified statistical batteries on specified sample sizes. The standards most often cited are GLI-11 (which contains RNG requirements for gaming devices), GLI-19 for interactive systems, and the technical standards of the licensing regulator, such as the UK Gambling Commission’s RTS, which requires RNGs in remote gambling products to be tested by an approved test house.

Beyond the statistics, standards address implementation behaviour: that the generator cannot be influenced by the game or the player, that re-seeding occurs, that scaling is unbiased, that unused outputs are not exposed in a way that leaks state, and that the certified module is the one actually in use (version control and file hashing). The certification page covers how these certificates are scoped and recognised.

Outcome independence and common misconceptions

If the pipeline above is sound, each outcome is independent of every previous one. The generator has no memory of what the game showed, no notion of whether a player is “due”, and no mechanism by which the time of day, the stake size or the length of a session alters the next number. Several widely held beliefs are inconsistent with this property:

BeliefWhy it conflicts with independence
“The machine is hot / cold.”Streaks are an expected feature of independent sequences. Their presence is evidence of randomness, not against it.
“A big win is due after a long dry spell.”The gambler’s fallacy. Probability of the next outcome is unchanged by history; the paytable, not the past, sets it.
“Near misses show the game is about to pay.”The displayed near miss is a presentation choice made after the outcome is fixed. It carries no information about the next draw.
“Betting at certain times or stakes changes the odds.”A certified RNG and game logic have no input from clock or stake in outcome selection. (Stake can change the paytable in some games — that is a rule, published, not a randomness effect.)
“Patterns in the last 50 results predict the next.”Fifty outcomes cannot distinguish a fair generator from almost anything. See sample size.

Independence is also what makes RTP a long-run concept. The RTP page shows how many independent outcomes it takes before an observed return says anything.

What an audit can and cannot prove

An RNG audit can establish

  • The algorithm is a recognised construction and the implementation matches its specification.
  • Seeding draws on an assessed entropy source and re-seeds on schedule.
  • Output passes named statistical batteries at stated sample sizes.
  • Scaling to the game range is unbiased or has documented, immaterial bias.
  • The reviewed module is identifiable by version and hash.

An RNG audit cannot establish

  • What the next outcome will be, or that any player will win or lose.
  • That the deployed binary is the tested one — that needs ongoing version control and monitoring.
  • That the game’s paytable or RTP is favourable; those are separate layers.
  • That the operator pays out, honours terms or is licensed.
  • Anything about a version released after the test date.

Reading an RNG certificate

When a certificate or test report is available, these fields determine what it is worth:

  • Issuer — a recognised laboratory, and ideally one approved by the relevant regulator.
  • Artefact — algorithm name, software version, and a hash or build identifier of the tested module.
  • Standard — the document and version tested against (for example GLI-11 v3.x, or a regulator’s RTS).
  • Scope — which stages of the pipeline were examined: entropy, algorithm, scaling, integration into specific games.
  • Method — statistical suites run, sample sizes, significance thresholds.
  • Date and validity — when tested, and whether re-testing is required after changes.

The Randomness section of the fairness checklist turns this list into tick-boxes.

Sources

  1. NIST, SP 800-22 Rev. 1a: A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications. csrc.nist.gov
  2. NIST, SP 800-90A Rev. 1: Recommendation for Random Number Generation Using Deterministic Random Bit Generators. csrc.nist.gov
  3. NIST, SP 800-90B: Recommendation for the Entropy Sources Used for Random Bit Generation. csrc.nist.gov
  4. Gaming Laboratories International, GLI-11: Gaming Devices in Casinos and GLI-19: Interactive Gaming Systems. gaminglabs.com
  5. UK Gambling Commission, Remote gambling and software technical standards. gamblingcommission.gov.uk
  6. R. G. Brown, Dieharder: A Random Number Test Suite. webhome.phy.duke.edu
  7. P. L’Ecuyer and R. Simard, “TestU01: A C library for empirical testing of random number generators”, ACM Transactions on Mathematical Software 33(4), 2007. doi:10.1145/1268776.1268777
  8. M. Matsumoto and T. Nishimura, “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator”, ACM Transactions on Modeling and Computer Simulation 8(1), 1998. doi:10.1145/272991.272995
  9. D. E. Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed., Addison-Wesley, 1997 — chapter 3, “Random Numbers”.