Park-Miller minimal standard PRNG from Numerical Recipes. Simple multiplicative linear congruential generator using Schrageβs method to compute (16807 Γ seed) mod (2^31-1) without overflow. Returns floating-point values in [0.0, 1.0). Superseded by Ran2 and Ran3, but useful for educational purposes and as a reference implementation.
| Property | Value |
|---|---|
| Category | Random Number Generators |
| Sub-category | Linear Congruential Generator |
| Security status | π Educational Only |
| Complexity | Beginner |
| Inventor | Stephen K. Park and Keith W. Miller |
| Year | 1988 |
| Origin | πΊπΈ United States |
| Source | algorithms/random/ran0.js |
| Parameter | Supported values |
|---|---|
| Seed sizes | 1 byte (8 bits) to 4 bytes (32 bits) |
| Flag | Value |
|---|---|
IsDeterministic |
Yes |
IsCryptographicallySecure |
No |
Status: π Educational Only
No vulnerabilities are recorded for this implementation.
5 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 β Seed=1: First 10 output values (floating-point doubles)
| Field | Value |
|---|---|
seed |
00000001 |
outputSize |
80 |
input |
null |
expected |
80d32000c069e03e76ac21f13ad6c03f d65b7036eb2de83f0cb53a15865add3f dc18a2e06d0ce13fb60d38c8da06cc3f 772c30603b16a83f8572ab7f42b9e53f 9879ebd0cbbce53f02d27b1301e9ed3f |
Vector 2 β Seed=123456789: First 5 output values
| Field | Value |
|---|---|
seed |
075bcd15 |
outputSize |
40 |
input |
null |
expected |
43ea377921f5cb3f4f347d51279aee3f ae16f5f2568bea3fd1f2a3b868f9e13f c82835276494da3f |
Vector 3 β Park-Miller canonical test: 10,000th iteration from seed=1
| Field | Value |
|---|---|
seed |
00000001 |
count |
10000 |
outputSize |
8 |
input |
null |
expected |
5934be882c1adf3f |
Vector 4 β Seed=16807 (multiplier a): First value
| Field | Value |
|---|---|
seed |
000041a7 |
outputSize |
8 |
input |
null |
expected |
76ac21f13ad6c03f |
Vector 5 β Seed=2147483646 (max valid seed): First value
| Field | Value |
|---|---|
seed |
7ffffffe |
outputSize |
8 |
input |
null |
expected |
dfff3f96efffef3f |