Chi-Square Test

Chi-Square Test for continuous distributions.
9.9K Downloads
Updated 21 Apr 2004

View License

[A, B] = CHI2TEST(DATA, N, ALPHA, DIST, X, Y, Z) returns the chi-square statistic for the samples contained in the row vector DATA.

N specifies the number of equal-probability class intervals for the test. ALPHA is the confidence level parameter used to find the critical chi-square value.

DIST is a string containing the probability distribution that we are testing against. See the staitsctics toolbox for supported distributions - 'exp', 'gam', 'unif' are some of them.

X, Y, and Z specify the estimated parameters for the selected DIST. Some distributions require only one of these parameters, and the order that these parameters are provided follows the values given to the cummulative distribution functions UNIFCDF, GAMCDF, EXPCDF, and others.

A is the computed chi-square statistic, and B is the critical tabulated value at the degrees of freedom. The degree of freedom is the number of intervals minus the number of estimated parameters.

In general, if A is less than B, the H0 hypothesis that DATA follows the DIST distribution is accepted.

An attempt to fit some data with the uniform distribution on the interval from 1.5 to 2.9. The test fails, since A > B:

[a, b] = chi2test (data, 10, 0.05, 'unif', 1.5, 2.9)
a =
38.7500
b =
14.0671

See also MLE, CHI2INV, CHI2STAT, HIST, CDF, ICDF, PDF

Cite As

Leonardo Salomone (2024). Chi-Square Test (https://www.mathworks.com/matlabcentral/fileexchange/4779-chi-square-test), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0