Solved – Excel’s CHIDIST function in MATLAB

chi-squared-distributionchi-squared-testexcelMATLAB

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.

Best Answer

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)
Related Question