[Scipy-svn] r5564 - in trunk/scipy/stats: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Feb 18 23:43:43 EST 2009
Author: josef
Date: 2009-02-18 22:43:39 -0600 (Wed, 18 Feb 2009)
New Revision: 5564
Modified:
trunk/scipy/stats/stats.py
trunk/scipy/stats/tests/test_stats.py
Log:
fix removal of var in obrientransform, add regression test
Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py 2009-02-19 04:30:03 UTC (rev 5563)
+++ trunk/scipy/stats/stats.py 2009-02-19 04:43:39 UTC (rev 5564)
@@ -1232,17 +1232,17 @@
for i in range(k):
nargs.append(args[i].astype(float))
n[i] = float(len(nargs[i]))
- v[i] = var(nargs[i])
- m[i] = mean(nargs[i],None)
+ v[i] = np.var(nargs[i], ddof=1)
+ m[i] = np.mean(nargs[i])
for j in range(k):
- for i in range(n[j]):
+ for i in range(n[j]): # raises warning because n[j] is float
t1 = (n[j]-1.5)*n[j]*(nargs[j][i]-m[j])**2
t2 = 0.5*v[j]*(n[j]-1.0)
t3 = (n[j]-1.0)*(n[j]-2.0)
nargs[j][i] = (t1-t2) / float(t3)
check = 1
for j in range(k):
- if v[j] - mean(nargs[j],None) > TINY:
+ if v[j] - np.mean(nargs[j]) > TINY:
check = 0
if check != 1:
raise ValueError, 'Lack of convergence in obrientransform.'
Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py 2009-02-19 04:30:03 UTC (rev 5563)
+++ trunk/scipy/stats/tests/test_stats.py 2009-02-19 04:43:39 UTC (rev 5564)
@@ -1238,6 +1238,15 @@
assert_equal(v, vc)
assert_array_almost_equal(sk, skc, decimal=13) #not sure about precision
assert_array_almost_equal(kurt, kurtc, decimal=13)
+
+def test_obrientransform():
+ #this is a regression test to check np.var replacement
+ #I didn't separately verigy the numbers
+ x1 = np.arange(5)
+ result = np.array(
+ [[ 5.41666667, 1.04166667, -0.41666667, 1.04166667, 5.41666667],
+ [ 21.66666667, 4.16666667, -1.66666667, 4.16666667, 21.66666667]])
+ assert_array_almost_equal(stats.obrientransform(x1, 2*x1), result, decimal=8)
More information about the Scipy-svn
mailing list