Middle Squares is a simple PRNG.
.column[
* Choose an n-digit seed
* Square the seed, padding leading zeros if fewer than n+n digits
* Use the middle n digits as the next seed
* Repeat
]
.column[
PRNG |
Period |
Notes |
KISS99 |
2^37 |
The short period renders this PRNG inappropriate for many simulations
situations. |
Mersenne-Twister |
2^19,937 |
Uses 2.5Kb of memory. It passes Diehard tests and most of the Dieharder
and TestU01 tests. It is not appropriate for multi-stream work flows.
|
L'Ecuyer-CMRG |
2^191 |
Produces multiple streams of random numbers from a single seed, making
it appropriate for multi-stream work flows. |
???
Multiple streams of random numbers, in the case of L'Ecuyer, is more valuable
than providing an individual stream to each process because the one algorithm's
streams never get into sync.
KISS example code:
```
static unsigned int x = 123456789,y = 362436000,z = 521288629,c = 7654321; /* Seed variables */ unsigned int KISS()
{ unsigned long long t, a = 698769069ULL;
x = 69069*x+12345; y ^= (y<<13); y ^= (y>>17); y ^= (y<<5); /* y must never be set to zero! */ t = a*z+c; c = (t>>32); /* Also avoid setting z=c=0! */
return x+y+(z=t); }
```
---
name: Terrible
class:
## {{ name }}