Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test for randomness : Chi square test

Similar presentations


Presentation on theme: "Test for randomness : Chi square test"— Presentation transcript:

1 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? December 1999 Prabhas Chongstitvatana

2 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 December 1999 Prabhas Chongstitvatana

3 Prabhas Chongstitvatana
Expanding (Ys – nps) 2 = Y2 – 2nps Ys + n2 ps 2 and Y1 + Y2 + … Yk = n p1 + p2 + … pk = 1 v = k –1 the number of degree of freedom is k – 1. December 1999 Prabhas Chongstitvatana

4 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 December 1999 Prabhas Chongstitvatana

5 Prabhas Chongstitvatana
Example five Chi-square test on three data of four generators. December 1999 Prabhas Chongstitvatana

6 Prabhas Chongstitvatana
B : x0 = 0, a = , c = , m = 2 35 C : x0 = 0, a = , c = 1, m = 2 35 D : x0 = , a = 23, c = 0, m = F : x0 = , a = , c = 1, m = 2 35 Conclusion, B and D are satisfactory, C is on the borderline, F is unsatisfactory. December 1999 Prabhas Chongstitvatana

7 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 December 1999 Prabhas Chongstitvatana

8 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. December 1999 Prabhas Chongstitvatana

9 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. December 1999 Prabhas Chongstitvatana

10 Prabhas Chongstitvatana
Some good RNG a, m 137, 256 , 235 5 15, 2 35 , 2 35 , 2 32 , , 2 48 , 2 64 December 1999 Prabhas Chongstitvatana


Download ppt "Test for randomness : Chi square test"

Similar presentations


Ads by Google