[Scipy-svn] r6953 - in trunk/scipy/stats: . tests

scipy-svn@scip... scipy-svn@scip...
Sun Nov 28 02:56:36 CST 2010


Author: rgommers
Date: 2010-11-28 02:56:36 -0600 (Sun, 28 Nov 2010)
New Revision: 6953

Modified:
   trunk/scipy/stats/mstats_basic.py
   trunk/scipy/stats/tests/test_mstats_basic.py
Log:
BUG: mstats.linregress was returning one value too many. Add basic test. Closes #1273.

Modified: trunk/scipy/stats/mstats_basic.py
===================================================================
--- trunk/scipy/stats/mstats_basic.py	2010-11-28 04:52:01 UTC (rev 6952)
+++ trunk/scipy/stats/mstats_basic.py	2010-11-28 08:56:36 UTC (rev 6953)
@@ -647,7 +647,7 @@
     slope = Sxy / Sxx
     intercept = ymean - slope*xmean
     sterrest = ma.sqrt(1.-r*r) * y.std()
-    return slope, intercept, r, prob, sterrest, Syy/Sxx
+    return slope, intercept, r, prob, sterrest
 
 if stats.linregress.__doc__:
     linregress.__doc__ = stats.linregress.__doc__ + genmissingvaldoc

Modified: trunk/scipy/stats/tests/test_mstats_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_mstats_basic.py	2010-11-28 04:52:01 UTC (rev 6952)
+++ trunk/scipy/stats/tests/test_mstats_basic.py	2010-11-28 08:56:36 UTC (rev 6953)
@@ -528,6 +528,17 @@
         assert_almost_equal(result[1], 0.5692, 4)
 
 
+def test_regress_simple():
+    """Regress a line with sinusoidal noise. Test for #1273."""
+    x = np.linspace(0, 100, 100)
+    y = 0.2 * np.linspace(0, 100, 100) + 10
+    y += np.sin(np.linspace(0, 20, 100))
+
+    slope, intercept, r_value, p_value, sterr = mstats.linregress(x, y)
+    assert_almost_equal(slope, 0.19644990055858422)
+    assert_almost_equal(intercept, 10.211269918932341)
+
+
 def test_plotting_positions():
     """Regression test for #1256"""
     pos = mstats.plotting_positions(np.arange(3), 0, 0)



More information about the Scipy-svn mailing list