0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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). $\endgroup$
    – whuber
    Jun 20 '11 at 21:32
2
$\begingroup$

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)
$\endgroup$
1
  • $\begingroup$ You are right. It's my mistake in the formula understanding. Thanks. $\endgroup$
    – yuk
    Jun 20 '11 at 21:31
0
$\begingroup$

The equivalent of CHIDIST in matlab would be using chi2cdf with the argument 'upper'. This returns the complement of chi2 cdf at the value of the chi square statistic.

chi2cdf(x,df,'upper')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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