The StatsChiTest operation supports two types of tests. The first is a comparison of two distributions. The second is a test comparing a binned distribution against expected values.

Comparing two distributions

In this example we generate two Gaussian pseudo-random distributions with the same standard deviation. We then compute and plot their histograms and finally we run the Chi-Test on the histograms.

Make/O/N=1e5 ddd,eee        // create waves
ddd=gnoise(15,2)        // fill with Gaussian noise
eee=gnoise(15,2)
Histogram/B={-80,1,160} eee,eh      // compute histograms
Histogram/B={-80,1,160} ddd,dh
Graph0()                        // display histograms<
StatsChiTest/T=1  eh,dh

The results in the "Chi-Squared Test" table should be similar to the following:

n 118
df 117
Chi_Squared 132.712
Critical 143.246
P 0.152077

Your result may be somewhat different because the histograms of the waves fluctuate as a result of the pseudo-random number generator. However, because of the way the data were created, the basic Chi-Squared value should be lower than the critical value which is determined by the degrees of freedom and the significance level (set to 0.05 by default). This confirms that the two distributions are the same.

Comparison with expected values

The second type of Chi-Test is a comparison of binned distribution with expected values. Here we test one of the histograms generated above against an expected distribution contained in the wave called "expected". To run the test execute the commands:

StatsChiTest/T=1/S eh,expected
Graph1()

The results in the "Chi-Squared Test" table should be similar to the following:

n 124
df 123
Chi_Squared 96.2393
Critical 149.885
P 0.964474

In this case again the Chi-Squared value is smaller than the critical value so we can't reject H0 that the tested sample agrees with the expected distribution.

Sample Size

It is interesting to examine the departure of the histogram from a perfect Gaussian form when we reduce the size of the psuedo-random wave. To test this, execute the following commands:

Make/O/N=10000 fff=gnoise(15,2)
Histogram/B={-80,1,160} fff,fh
StatsChiTest/T=1/S  fh,expected2
Graph2()

The results in the "Chi-Squared Test" table should be similar to the following:

n 104
df 103
Chi_Squared 215.429
Critical 127.689
P 6.06415e-10

In this case Chi-Squared is larger than the critical values and the histogram does not match the expected values. Note that expected2 was derived from the wave expected by simple scaling to compensate for the smaller sample size.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More