I need to do a linear congruential generator that will successfully pass the selected statistical tests.
My question is: how to choose numbers for the generator properly and which statistical tests should I choose?
I thought about:
-
Chi-Square Frequency Test for Uniformity
-
Collect 10,000 numbers per generation method
-
Sub-divide[0.1) into 10 equal subdivisions
-
-
Kolmogorov-Smirnov Test for uniformity
- Since K-S Test works better with a smaller set of numbers, you may use the first 100 out fo the 10,000 that you generated for the Chi-Square Frequency Test
Here is the code example:
a = 30202383
c = 99282983
m = 16483727
xi = 16**56
def seed(x):
global xi
xi = x
def rng():
global xi
xi = (a*xi + c)%m
return xi
for i in range(10):
print (rng())
Aucun commentaire:
Enregistrer un commentaire