Code covered by the BSD License  

Highlights from
Chi-Square Test

3.75

3.8 | 4 ratings Rate this file 25 Downloads (last 30 days) File Size: 2.64 KB File ID: #4779

Chi-Square Test

by Leonardo Salomone

 

19 Apr 2004 (Updated 21 Apr 2004)

Chi-Square Test for continuous distributions.

| Watch this File

File Information
Description

[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

Required Products Statistics Toolbox
MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
12 Oct 2004 fishwine huang

thank you

12 Mar 2005 elsa m

I get this error:
??? One or more output arguments not assigned during call to 'chi2test'.

what am i doing wrong??

23 Sep 2005 Tshiamo Motshegwa

>>[a, b] = chi22test (out_data, 70, 0.05, 'unif',28580,5076)
??? Error using ==> minus
Matrix dimensions must agree.

Error in ==> chi22test at 100
chi2bins = ((o_freq - e_freq).^2)./e_freq;

03 Dec 2005 Reuben Stahls

Hi,

Was wondering if you could reply to this question. I have a Gaussian random vector with a non-zero mean and I would like to compute the probability that the frobenius of this random vector is less than some constant. Is there any available matlab function that can help me achieve my goal.

Thanks for your response in advance.

Best wishes,
Reuben Stahls

25 Jul 2006 Nasir Ali

good

25 Jul 2006 manj benning

0_freq is a row vec and e_freq is a column vec...so i had to modify line 100
chi2bins = ((o_freq' - e_freq).^2)./e_freq;
to make it work.

28 May 2007 JianfeiWu Wu  
02 Jan 2009 Rimvydas

I think the line for calculation of p value should be corrected
from
pval=1-gammainc(x2/2, (length(O)-3)/2); %p value
to
pval=1-gammainc(x2/2, (length(O)-1)/2); %p value
since degrees of freedom as gamma function parameter was incorrectly defined

28 Aug 2010 Zuhal

i have wind speed data including 365 values. how can we define the "n" value?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Leonardo Salomone 22 Oct 2008 07:18:06
probability Leonardo Salomone 22 Oct 2008 07:18:06
chi2test Leonardo Salomone 22 Oct 2008 07:18:06
chisquare Leonardo Salomone 22 Oct 2008 07:18:06
chi2test farouq razzaz 22 Apr 2011 14:22:03
chi2test manuela 05 Aug 2011 03:50:06

Contact us at files@mathworks.com