100 likes | 378 Views
Test for randomness : Chi square test. We can say how probable or improbable certain types of events are. The difference between observed Y s and expected np s V = (Y 2 – np 2 ) 2 + (Y 3 – np 3 ) 2 + … + (Y 12 – np 12 ) 2 What is the probability what V is this high using true dice?.
E N D
Test for randomness : Chi square test We can say how probable or improbable certain types of events are. The difference between observed Ys and expected nps V = (Y2 – np2) 2 + (Y3 – np3) 2 + … + (Y12 – np12) 2 What is the probability what V is this high using true dice? Prabhas Chongstitvatana
Suppose that every observation can fall into one of k categories. We take n independent observations. Let ps be the probability that each observation falls into category s, and let Ys be the number of observations that actually do fall into category s. Weighted by the prob. of occurrence nps Prabhas Chongstitvatana
Expanding (Ys – nps) 2 = Y2 – 2nps Ys + n2 ps2 and Y1 + Y2 + … Yk = n p1 + p2 + … pk = 1 v = k –1 the number of degree of freedom is k – 1. Prabhas Chongstitvatana
Chi-square distribution table says “The quantity V will be less than or equal to x with approximate probability p, if n is large enough”. How large should n be? Rule of thumb is nps>= 5 Prabhas Chongstitvatana
Example five Chi-square test on three data of four generators. Prabhas Chongstitvatana
B : x0 = 0, a = 3141592653, c = 2718281829, m = 2 35 C : x0 = 0, a = 2 7 + 1 , c = 1, m = 2 35 D : x0 = 47194118, a = 23, c = 0, m = 10 8 + 1 F : x0 = 314159265, a = 2 18 + 1, c = 1, m = 2 35 Conclusion, B and D are satisfactory, C is on the borderline, F is unsatisfactory. Prabhas Chongstitvatana
Other tests Kolmogorov-Smirnov test (available in SPSS package) Frequency test, serial test, gap test, Poker test (partition test), Coupon’s collector test, permutation test, run test, maximum-of-t test, collision test, serial correlation test, tests on subsequences Spectral test Prabhas Chongstitvatana
Advise for RNG The seed number X0 may be chosen arbitrarily. The number m should be large. The computation (aX + c) mod m must be done exactly with no roundoff error. If m is the power of 2, pick a so that a mod 8 = 5 to ensure max period and high potency. Prabhas Chongstitvatana
The muliplier a should preferably be chosen between .01m and .99m and is binary digits should not have a simple, regular pattern. The value of c is immaterial when a is a good multiplier, except that c must be no factor in common with m. The least significant (right-handed) digits of X are not very random. It is generally best to think of X as a random fraction X/m between 0 and 1. Prabhas Chongstitvatana
Some good RNG a, m 137, 256 3141592221, 235 5 15, 2 35 17059465, 2 35 1664525, 2 32 314159269, 2 31 - 1 31167285, 2 48 6364136223846793005, 2 64 Prabhas Chongstitvatana