[SciPy-dev] changes to stats t-tests

Jarrod Millman millman@berkeley....
Sun Dec 21 02:03:53 CST 2008

On Sat, Dec 20, 2008 at 11:33 AM,  <josef.pktd@gmail.com> wrote:
> I finally looked at the t-test in more detail and I would like to make
> three changes to the ttests

Thanks for looking into this.

> 1) ttest_1samp: add axis argument, it is the only ttest and similar
> function without an axis argument. Currently the retrun for multi
> dimensional arrays is wrong, the array is flattened for the
> calculation of mean and variance, but the number of observations is
> taken along axis 0 (Test suite only check for 1-dim case).
> One problem is the default axis, the usual default axis in statistics,
> scipy.stats is zero, but it is not always consistently used
> ttest_rel(a,b,axis=None), ttest_ind(a, b, axis=0), sem(a, axis=0)

+1 to adding axis arg to ttest_1samp.  I would set the default axis to
0 in all cases (i.e., I would also like to see ttest_rel default to

> 2) return for t statistic: return number instead of 0-dimensional
> array, no changes for higher dimensions
>     Same for all three tests.
> current return (t-statistic, p-value)
> (array(0.81248591389165681), 0.41846234511362179)
> proposed return
> (0.81248591389165681, 0.41846234511362179)


> 3) clean up handling of zero division problem: current zero division
> problem doesn't make sense, it return a t-statistic  arbitrarily set
> to one. This only applies to cases with zero variance
>    proposed change, return either inf (if numerator different from
> zero) or zero (if numerator is also zero.

I would think that for a/0=x:
  a > 0  then x is +inf
  a < 0  then x is -inf
  a = 0 then x is NaN

Why would x be 0 when a is 0?  Regardless, I agree that the current
behavior is incorrect and needs to be fixed.

> Since, we are just before release, I don't know if I can make these
> changes now or after the release. Most of it fixes incorrect returns,
> and I'm writing the tests for all cases.

I would like to see these changes make it into the 0.7 release.
Especially if you write tests and document the changes.  Can you make
the changes before the end of the weekend?


More information about the Scipy-dev mailing list