Simulation and Modelling - Old Questions

2. Differentiate between chi-square test and KS test for uniformity. Use KS test to check for the uniformity for the input set of random numbers given below.0.54, 0.73, 0.98, 0.11,0.68,0.45. Assume level of significance to be Dα = 0.05=> 0.565.

10 marks | Asked in 2076 (new)

The Chi Square test is used to test whether the distribution of nominal variables is same or not as well as for other distribution matches and on the other hand the Kolmogorov Smirnov (K-S) test is only used to test to the goodness of fit for a continuous data.

Kolmogorov Smirnov (K-S) test compares the continuous cdf, F(X), of the uniform distribution to the empirical cdf, SN(x), of the sample of N observations. By definition,

    F(x) = x, 0 <= x <= 1

If the sample from the random-number generator is R1, R2,......,RN, then the empirical cdf, SN(X), is defined by

    SN(X) = (Number of R1, R2,......,RN which are <= x)/N

As N becomes larger, SN(X) should become a better approximation to F(X), provided that the null hypothesis is true. The Kolmogorov-Smirnov test is based on the largest absolute deviation or difference between F(x) and SN(X) over the range of the random variable. I.e. it is based on the statistic

    D = max | F(x) - SN(x)|


The chi-square test uses the sample statistic

Where Oi is the observed number in the ith class, Ei is the expected number in the ith class, and n is the number of classes. For the uniform distribution, Ei ist the expected number in each class is given by: Ei = N/n, N is the total number of observation.


Now,

Given sequence of number,

    0.54, 0.73, 0.98, 0.11,0.68 and 0.45

Arranging the given number in ascending order:

    0.11, 0.45, 0.54, 0.68, 0.73, 0.98

Here, N = 6

Calculation table for Kolmogorov-Smirnov test :

i



10.110.170.060.11
20.450.33-0.28
30.540.5-0.21
40.680.670.070.18
50.730.830.10.06
60.9810.020.15

Now, calculating

\\begin{displaymath}D^+ = {\\rm max}_{1 \\le i \\le N} \\left\\{ \\frac{i}{N} - R_{(i)}
\\right\\} \\end{displaymath} = 0.1

\\begin{displaymath}D^- = {\\rm max}_{1 \\le i \\le N} \\left\\{ R_{(i)} -
\\frac{i-1}{N} \\right\\} \\end{displaymath} = 0.28

$D = {\\rm max} (D^+, D^-)$ = 0.28

Given, Critical value $D_\\alpha$ = 0.565

Since the computed value, D = 0.28, is less than the tabulated critical value, $D_\\alpha$ = 0.565, the hypothesis of no difference between the distribution of the generated numbers and the uniform distribution is not rejected.