RNG Algorithm Comparator

Compare different random number generator algorithms and their statistical properties

Algorithm Selection

Generation Parameters

Help

Linear Congruential Generator (LCG)

One of the oldest and simplest pseudo-random number generators. Uses the formula: X(n+1) = (a * X(n) + c) mod m

Pros: Fast, simple, memory efficient

Cons: Poor quality, short period, correlation in lower bits

Use case: Simple simulations where quality is not critical

Mersenne Twister

A widely-used PRNG with excellent statistical properties and a very long period (2^19937 - 1).

Pros: Excellent statistical properties, long period, passes most statistical tests

Cons: Not cryptographically secure, uses more memory, slower initialization

Use case: Monte Carlo simulations, scientific computing, games

XorShift

A fast PRNG using XOR and bit-shift operations. Very efficient with reasonable quality.

Pros: Very fast, small state, good quality for most purposes

Cons: Not cryptographically secure, shorter period than MT

Use case: Games, simulations where speed is important

Mulberry32

A simple and fast 32-bit PRNG with good statistical properties.

Pros: Fast, simple, good quality for a 32-bit generator

Cons: 32-bit period, not cryptographically secure

Use case: Quick simulations, testing, procedural generation

Statistical Tests
  • Mean: Should be close to 0.5 for uniform [0,1] distribution
  • Variance: Should be close to 1/12 ≈ 0.0833 for uniform [0,1]
  • Chi-Square: Tests uniformity across bins (lower is better, p > 0.05 is good)
  • Kolmogorov-Smirnov: Tests if distribution matches uniform (p > 0.05 is good)
  • Runs Test: Tests for independence (checks for patterns)
Understanding the Visualizations
  • Distribution Histogram: Should be flat/uniform for good RNG
  • 2D Pattern: Pairs of consecutive numbers; should show no patterns
  • Serial Correlation: Should show no correlation between consecutive values