Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

How to reproduce MS Excel's CHIDIST function in MATLAB?

Returns the one-tailed probability of the chi-squared distribution. The χ2 distribution is associated with a χ2 test. Use the χ2 test to compare observed and expected values. For example, a genetic experiment might hypothesize that the next generation of plants will exhibit a certain set of colors. By comparing the observed results with the expected ones, you can decide whether your original hypothesis is valid.

Syntax

CHIDIST(x,degrees_freedom)

X is the value at which you want to evaluate the distribution.

Degrees_freedom is the number of degrees of freedom.

So, if I have column of numbers as x and use the formula like =CHIDIST(A1:A60,3), it returns 1 number.

I have tried to follow two advices from this thread, but I always get a vector of numbers, not one number.

Thanks

share|improve this question
CHIDIST, like many Excel functions, works when applied to arrays: it threads over the array in this case and returns one value for each of the 60 cells in the range a1:a60. (Tested with Excel 2002.) If you do not enter it as an array function, the value you are getting is the first value: in this case, it will equal CHIDIST(A1, 3). – whuber Jun 20 '11 at 21:32
Yes, I already found my mistake. Thanks. – yuk Jun 21 '11 at 1:12

1 Answer

up vote 1 down vote accepted

Are you sure you're using the correct function? CHIDIST in excel takes a single number, not an array. chidist(a1:a60,3) doesn't make sense in this case.

Using the code from the MATLAB thread you mentioned, the following are equivalent:

CHIDIST(x,df) (in Excel)
1-chi2cdf(x,df) (in MATLAB)
share|improve this answer
You are right. It's my mistake in the formula understanding. Thanks. – yuk Jun 20 '11 at 21:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.