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

scipy-svn@scip... scipy-svn@scip...
Fri Jan 22 08:22:25 CST 2010


Author: josef
Date: 2010-01-22 08:22:25 -0600 (Fri, 22 Jan 2010)
New Revision: 6210

Modified:
   trunk/scipy/stats/morestats.py
Log:
stats.anderson: quickfix to gumbel, use fit to estimate loc,scale, no tests yet, see ticket:1097

Modified: trunk/scipy/stats/morestats.py
===================================================================
--- trunk/scipy/stats/morestats.py	2010-01-21 04:37:59 UTC (rev 6209)
+++ trunk/scipy/stats/morestats.py	2010-01-22 14:22:25 UTC (rev 6210)
@@ -596,19 +596,24 @@
         z = distributions.logistic.cdf(w)
         sig = array([25,10,5,2.5,1,0.5])
         critical = around(_Avals_logistic / (1.0+0.25/N),3)
-    else:
-        def fixedsolve(th,xj,N):
-            val = stats.sum(xj)*1.0/N
-            tmp = exp(-xj/th)
-            term = sum(xj*tmp,axis=0)
-            term /= sum(tmp,axis=0)
-            return val - term
-        s = optimize.fixed_point(fixedsolve, 1.0, args=(x,N),xtol=1e-5)
-        xbar = -s*log(sum(exp(-x/s),axis=0)*1.0/N)
+    elif (dist == 'gumbel') or (dist == 'extreme1'):
+        #the following is incorrect, see ticket:1097
+##        def fixedsolve(th,xj,N):
+##            val = stats.sum(xj)*1.0/N
+##            tmp = exp(-xj/th)
+##            term = sum(xj*tmp,axis=0)
+##            term /= sum(tmp,axis=0)
+##            return val - term
+##        s = optimize.fixed_point(fixedsolve, 1.0, args=(x,N),xtol=1e-5)
+##        xbar = -s*log(sum(exp(-x/s),axis=0)*1.0/N)
+        xbar, s = distributions.gumbel_l.fit(x)
         w = (y-xbar)/s
         z = distributions.gumbel_l.cdf(w)
         sig = array([25,10,5,2.5,1])
         critical = around(_Avals_gumbel / (1.0 + 0.2/sqrt(N)),3)
+    else:
+        raise ValueError("dist has to be one of 'norm','expon','logistic'",
+                         "'gumbel','extreme1'")
     i = arange(1,N+1)
     S = sum((2*i-1.0)/N*(log(z)+log(1-z[::-1])),axis=0)
     A2 = -N-S



More information about the Scipy-svn mailing list