[Scipy-svn] r5562 - in trunk/scipy/stats: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Feb 18 21:58:26 EST 2009
Author: josef
Date: 2009-02-18 20:58:23 -0600 (Wed, 18 Feb 2009)
New Revision: 5562
Modified:
trunk/scipy/stats/stats.py
trunk/scipy/stats/tests/test_stats.py
Log:
fix describe, was broken with removal of stats.var; also min, max didn't have axis argument
Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py 2009-02-18 22:45:36 UTC (rev 5561)
+++ trunk/scipy/stats/stats.py 2009-02-19 02:58:23 UTC (rev 5562)
@@ -836,9 +836,10 @@
"""
a, axis = _chk_asarray(a, axis)
n = a.shape[axis]
- mm = (np.minimum.reduce(a), np.maximum.reduce(a))
- m = mean(a, axis)
- v = var(a, axis)
+ #mm = (np.minimum.reduce(a), np.maximum.reduce(a))
+ mm = (np.min(a, axis=axis), np.max(a, axis=axis))
+ m = np.mean(a, axis=axis)
+ v = np.var(a, axis=axis, ddof=1)
sk = skew(a, axis)
kurt = kurtosis(a, axis)
return n, mm, m, v, sk, kurt
Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py 2009-02-18 22:45:36 UTC (rev 5561)
+++ trunk/scipy/stats/tests/test_stats.py 2009-02-19 02:58:23 UTC (rev 5562)
@@ -1217,7 +1217,31 @@
anan = np.array([[1,np.nan],[-1,1]])
assert_equal(stats.ttest_1samp(anan, 0),([0, np.nan], [1,np.nan]))
+def test_describe():
+ x = np.vstack((np.ones((3,4)),2*np.ones((2,4))))
+ nc, mmc = (5, ([ 1., 1., 1., 1.], [ 2., 2., 2., 2.]))
+ mc = np.array([ 1.4, 1.4, 1.4, 1.4])
+ vc = np.array([ 0.3, 0.3, 0.3, 0.3])
+ skc = [0.40824829046386357]*4
+ kurtc = [-1.833333333333333]*4
+ n, mm, m, v, sk, kurt = stats.describe(x)
+ assert_equal(n, nc)
+ assert_equal(mm, mmc)
+ assert_equal(m, mc)
+ assert_equal(v, vc)
+ assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision
+ assert_array_almost_equal(kurt, kurtc, decimal=13)
+ n, mm, m, v, sk, kurt = stats.describe(x.T, axis=1)
+ assert_equal(n, nc)
+ assert_equal(mm, mmc)
+ assert_equal(m, mc)
+ assert_equal(v, vc)
+ assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision
+ assert_array_almost_equal(kurt, kurtc, decimal=13)
+
+
+
if __name__ == "__main__":
run_module_suite()
More information about the Scipy-svn
mailing list