Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random number generation #4

Open
qzhu2017 opened this issue Oct 24, 2018 · 0 comments
Open

Random number generation #4

qzhu2017 opened this issue Oct 24, 2018 · 0 comments

Comments

@qzhu2017
Copy link
Collaborator

The choice of m seems to generate very interesting phenomena.

%matplotlib inline
import matplotlib.pyplot as plt 
# We can only change [a , c , m]
N = 1000
a = 3125 #57
c = 19*17 #287
m = 10.99
x = 1
# This shows that a has to be in range 40<a<60 and c has to be in range of 200<c<300 for it to be somewhat random
results = []

for i in range(N):      
    x = (a*x+c)%m -5
    results.append(round(x))
plt.plot(results,"o")
plt.show()
plt.hist(results, bins=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant