Skip to main content

StatsChiTest

StatsChiTest [/NCON=nCon /S/Z] srcWave1, srcWave2

The StatsChiTest operation computes a

χ2\displaystyle \chi^{2}

statistic for comparing two distributions or a

χ2\displaystyle \chi^{2}

statistic for comparing a sample distribution with its expected values. In both cases the comparison is made on a bin-by-bin basis. Output is to the W_StatsChiTest wave in the current data folder or optionally to a table.

Flags

/ALZRAllows zero entries in source waves. If you are using /S zero entries in srcWave2 are skipped.
/DEST=sWaveSpecify the output wave for StatsChiTest. If you do not specify this flag, the operation stores the output in the wave W_StatsChiTest in the current data folder.
This flag was added in Igor Pro 10.00.
/FREECreates the specified destination wave as a free wave.
/FREE is allowed only in functions, and only if the destination waves are simple names or wave reference structure fields.
See Free Waves for more discussion.
The /FREE flag was added in Igor Pro 10.00.
/NCON=nConSpecifies the number of constraints (0 by default), which reduces the number degrees of freedom and the critical value by nCon.
/SSets the calculation mode to a single distribution where srcWave1 represents an array of binned measurements and srcWave2 represents the corresponding expected values.
/T=kDisplays results in a table. k specifies the table behavior when it is closed.
k =0:Normal with dialog (default).
k =1:Kills with no dialog.
k =2:Disables killing.
/ZIgnores errors. V_flag will be set to -1 for any error and to zero otherwise.

Details

The source waves, srcWave1 and srcWave2, must have the same number of points and can be any real numeric data type. Any nonpositive values (including NaN) in either wave removes the entry from consideration in both waves and reduces the degrees of freedom by one. The number degrees of freedom is initially the number of points in srcWave1-1-nCon. By default it is assumed that srcWave1 and srcWave2 represent two distributions of binned data.

When you specify /S, srcWave1 must consist of binned values of measured data and srcWave2 must contain the corresponding expected values. The calculation is:

χ2=i=0n1(YiVi)2Vi.\displaystyle \chi^{2}=\sum_{i=0}^{n-1} \frac{\left(Y_{i}-V_{i}\right)^{2}}{V_{i}} .

Here Yi is the sample point from srcWave1, Vi is the expected value of Yi based on an assumed distribution (srcWave2 ), and n is the number of points in the each wave. If you do not use /S, it calculates:

χ2=i=0n1(Y1iY2i)2Y1i+Y2i,\displaystyle \chi^{2}=\sum_{i=0}^{n-1} \frac{\left(Y_{1 i}-Y_{2 i}\right)^{2}}{Y_{1 i}+Y_{2 i}},

where Y1i and Y2i are taken from srcWave1 and srcWave2 respectively.

V_flag will be set to -1 for any error and to zero otherwise.

See Also

Statistical Analysis, StatsContingencyTable

Demos

Open Chi-Test Demo.pxp