# [Scipy-tickets] [SciPy] #1583: mstats.chisquare and stats.chisquare documentation is out of date

SciPy Trac scipy-tickets@scipy....
Wed Jan 11 16:03:59 CST 2012

```#1583: mstats.chisquare and stats.chisquare documentation is out of date
-------------------------+--------------------------------------------------
Reporter:  dloewenherz  |       Owner:  somebody
Type:  defect       |      Status:  new
Priority:  normal       |   Milestone:  Unscheduled
Component:  scipy.stats  |     Version:  devel
Keywords:               |
-------------------------+--------------------------------------------------
Changes (by dloewenherz):

Comment:

Well, maybe I am just getting confused, but the docs say that
stats.chisquare should return a tuple (I'm guessing) of the test statistic
and the p-value. The return values I'm seeing though look like they are
the statistics and p-values for each feature (was not expecting that).

So in order to check that the features as a whole pass the null hypothesis
(p<whatever), you have to sum the results of the first tuple and then feed
that value into inverse CDF for the chi-square distribution with the
correct degree of freedom.

Maybe some examples would be helpful as well?

Thank you so much!

Regarding the ddof issue. Maybe I'm just bad at math (a possibility--
please correct me if I'm assuming something incorrectly), but here is a
table I played around with to illustrate.

{{{
>> table=np.array([(6, 17, 13, 9, 5), (13,5,7, 16, 9)])
(array([ 2.57894737,  6.54545455,  1.8       ,  1.96      ,  1.14285714]),
array([ 0.10829366,  0.01051525,  0.17971249,  0.16151332,  0.28504941]))
>> stats.chisquare(table, ddof=4) # what ddof should be by default with
this table
(array([ 2.57894737,  6.54545455,  1.8       ,  1.96      ,  1.14285714]),
array([ nan,  nan,  nan,  nan,  nan]))
>> stats.chisquare(table, ddof=5) # another value to illustrate static
return values
(array([ 2.57894737,  6.54545455,  1.8       ,  1.96      ,  1.14285714]),
array([ nan,  nan,  nan,  nan,  nan]))
}}}

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1583#comment:2>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```