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

scipy-svn@scip... scipy-svn@scip...
Sun Jan 17 23:20:15 CST 2010


Author: josef
Date: 2010-01-17 23:20:15 -0600 (Sun, 17 Jan 2010)
New Revision: 6207

Modified:
   trunk/scipy/stats/distributions.py
Log:
discrete distributions use floats in _drv2_moment, ticket:1069

Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py	2010-01-18 05:06:55 UTC (rev 6206)
+++ trunk/scipy/stats/distributions.py	2010-01-18 05:20:15 UTC (rev 6207)
@@ -3571,7 +3571,7 @@
     tot = 0.0
     diff = 1e100
     #pos = self.a
-    pos = max(0, self.a)
+    pos = max(0.0, 1.0*self.a)
     count = 0
     #handle cases with infinite support
     ulimit = max(1000, (min(self.b,1000) + max(self.a,-1000))/2.0 )
@@ -3579,7 +3579,7 @@
 
     while (pos <= self.b) and ((pos <= ulimit) or \
                                (diff > self.moment_tol)):
-        diff = pos**n * self.pmf(pos,*args)
+        diff = np.power(pos, n) * self.pmf(pos,*args)
         # use pmf because _pmf does not check support in randint
         #     and there might be problems ? with correct self.a, self.b at this stage
         tot += diff
@@ -3591,7 +3591,8 @@
         pos = -self.inc
         while (pos >= self.a) and ((pos >= llimit) or \
                                    (diff > self.moment_tol)):
-            diff = pos**n * self.pmf(pos,*args)  #using pmf instead of _pmf
+            diff = np.power(pos, n) * self.pmf(pos,*args)
+            #using pmf instead of _pmf, see above
             tot += diff
             pos -= self.inc
             count += 1



More information about the Scipy-svn mailing list