Chi-Squared Goodness-of-Fit Test

Test Purpose

The test verifies that the sample distribution function agrees with the hypothesized distribution. A chi-squared V statistic with the number of degrees of freedom that is minus one from the number of the intervals of partition is considered a stable response.

First Level Test

For a given parameter set and a given sample size, the test computes the partition of the distribution domain into disjoint intervals, so that the a priori quantity of random numbers from each interval is of order 100.

The test computes the actual number of random values within each interval of the generated sample and then calculates chi-square of the statistic V. The statistic V is asymptotically of chi-squared distribution Fk-1(x) with k - 1 degrees of freedom, where k is the number of the intervals. Thus, the p-value equal to Fk-1(V) should be of a distribution that is close to uniform.

Second Level Test

The first level test is run ten times, each run producing a p-value pj, j = 1, 2, ... , 10. The Kolmogorov-Smirnov goodness-of-fit test with Anderson-Darling’s statistics is applied to the obtained p-values pj j = 1, 2, ... , 10. If the resulting p-value pM

Interpreting Final Results

The final result of the test is the percentage FAIL of failed second level tests. The second level test is run ten times. The value of FAIL < 50% is considered acceptable.

For more complete information about compiler optimizations, see our Optimization Notice.
Select sticky button color: 
Orange (only for download buttons)