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

scipy-svn@scip... scipy-svn@scip...
Fri Nov 14 12:42:39 CST 2008


Author: josef
Date: 2008-11-14 12:42:37 -0600 (Fri, 14 Nov 2008)
New Revision: 5109

Modified:
   trunk/scipy/stats/distributions.py
Log:
fix (non-convergent) moment calculation of loggamma; force var to be inf if mean is inf, instead of nan

Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py	2008-11-14 15:28:34 UTC (rev 5108)
+++ trunk/scipy/stats/distributions.py	2008-11-14 18:42:37 UTC (rev 5109)
@@ -720,6 +720,9 @@
                 if mu is None:
                     mu = self._munp(1.0,*goodargs)
                 mu2 = mu2p - mu*mu
+            if np.isinf(mu):
+                #if mean is inf then var is also inf
+                mu2 = np.inf
             out0 = default.copy()
             place(out0,cond,mu2*scale*scale)
             output.append(out0)
@@ -2324,6 +2327,9 @@
         return special.gammainc(c, exp(x))
     def _ppf(self, q, c):
         return log(special.gammaincinv(c,q))
+    def _munp(self,n,*args):
+        # use generic moment calculation using ppf
+        return self._mom0_sc(n,*args)
 loggamma = loggamma_gen(name='loggamma', longname="A log gamma",
                         extradoc="""
 



More information about the Scipy-svn mailing list