[Scipy-svn] r6985 - trunk/scipy/stats

scipy-svn@scip... scipy-svn@scip...
Fri Dec 3 01:21:30 CST 2010


Author: warren.weckesser
Date: 2010-12-03 01:21:30 -0600 (Fri, 03 Dec 2010)
New Revision: 6985

Modified:
   trunk/scipy/stats/stats.py
Log:
ENH: stats: Slight optimization in pearsonr--avoid a call of sqrt()

Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py	2010-12-03 06:56:20 UTC (rev 6984)
+++ trunk/scipy/stats/stats.py	2010-12-03 07:21:30 UTC (rev 6985)
@@ -2205,8 +2205,8 @@
     if abs(r) == 1.0:
         prob = 0.0
     else:
-        t = r * np.sqrt(df / ((1.0 - r) * (1.0 + r)))
-        prob = betai(0.5*df, 0.5, df / (df + t*t))
+        t_squared = r*r * (df / ((1.0 - r) * (1.0 + r)))
+        prob = betai(0.5*df, 0.5, df / (df + t_squared))
     return r, prob
 
 



More information about the Scipy-svn mailing list