Blum Blum Shub

Description

A pseudorandom number generator proposed in 1986 by Lenore Blum, Manuel Blum and Michael Shub.

Code Example

Python example:

m = 11*19 #large primes should be used
xi = 9

def rng():
    global xi
    xi = (xi * xi) % m
    return xi

for i in range(12):
    print rng()

Output:

81
82
36
42
92
104
157
196
169
137
168
9

This sequence has period 12. Careful selection of M is essential for large periods.

External Links

Blum Blum Shub - Wikipedia article on Blum Blum Shub.

Previous: Blum Blum Shub

Next: Caves

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License