Skip to content

Random number generation #4

Description

@qzhu2017

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions