Skip to content

Instantly share code, notes, and snippets.

@gerard
Created September 10, 2010 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerard/573759 to your computer and use it in GitHub Desktop.
Save gerard/573759 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import random
import matplotlib.pyplot as mpl_plot
import mpl_toolkits.mplot3d as mpl_plot3d
def simple_rand():
rand_next = 1
while True:
rand_next = rand_next * 1234567 + 12345
# rand_next = rand_next * 1103515245 + 12345;
rand_next = rand_next % (2**32)
yield rand_next
def get_random_f():
#return random.randint(0, 2**32-1)
#return random.SystemRandom().randint(0, 2**32-1)
return simple_rand()
get_random = get_random_f()
prev3 = get_random.next()
prev2 = get_random.next()
prev = get_random.next()
x = []
y = []
z = []
for i in range(0, 2**16-1):
new = get_random.next()
x.append(new - prev)
y.append(prev - prev2)
z.append(prev2 - prev3)
prev3 = prev2
prev2 = prev
prev = new
fig = mpl_plot.figure()
ax = mpl_plot3d.Axes3D(fig)
mpl_plot3d.Axes3D.scatter(ax, x, y, zs=z, linewidth=1)
mpl_plot.savefig("test-prng.png", format="png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment