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

scipy-svn@scip... scipy-svn@scip...
Mon Aug 27 08:30:23 CDT 2007


Author: stefan
Date: 2007-08-27 08:29:59 -0500 (Mon, 27 Aug 2007)
New Revision: 3263

Modified:
   trunk/scipy/stats/distributions.py
   trunk/scipy/stats/tests/test_distributions.py
Log:
Change distribution boundaries to be inclusive. Closes #488.


Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py	2007-08-25 23:15:34 UTC (rev 3262)
+++ trunk/scipy/stats/distributions.py	2007-08-27 13:29:59 UTC (rev 3263)
@@ -13,7 +13,7 @@
 from numpy import alltrue, where, arange, put, putmask, \
      ravel, take, ones, sum, shape, product, repeat, reshape, \
      zeros, floor, logical_and, log, sqrt, exp, arctanh, tan, sin, arcsin, \
-     arctan, tanh, ndarray, cos, cosh, sinh, newaxis
+     arctan, tanh, ndarray, cos, cosh, sinh, newaxis, array
 from numpy import atleast_1d, polyval, angle, ceil, place, extract, \
      any, argsort, argmax, vectorize, r_, asarray, nan, inf, pi, isnan, isinf
 import numpy
@@ -467,10 +467,10 @@
         args = tuple(map(arr,args))
         x = arr((x-loc)*1.0/scale)
         cond0 = self._argcheck(*args) & (scale > 0)
-        cond1 = (scale > 0) & (x > self.a) & (x < self.b)
+        cond1 = (scale > 0) & (x >= self.a) & (x <= self.b)
         cond = cond0 & cond1
         output = zeros(shape(cond),'d')
-        place(output,(1-cond0)*(cond1==cond1),self.badvalue)
+        putmask(output,(1-cond0)*array(cond1,bool),self.badvalue)
         goodargs = argsreduce(cond, *((x,)+args+(scale,)))
         scale, goodargs = goodargs[-1], goodargs[:-1]
         place(output,cond,self._pdf(*goodargs) / scale)

Modified: trunk/scipy/stats/tests/test_distributions.py
===================================================================
--- trunk/scipy/stats/tests/test_distributions.py	2007-08-25 23:15:34 UTC (rev 3262)
+++ trunk/scipy/stats/tests/test_distributions.py	2007-08-27 13:29:59 UTC (rev 3263)
@@ -211,5 +211,9 @@
         for s,p in zip(states,probability):
             assert abs(sum(x == s)/float(samples) - p) < 0.05
 
+class test_expon(NumpyTestCase):
+    def check_zero(self):
+        assert_equal(stats.expon.pdf(0),1)
+
 if __name__ == "__main__":
     NumpyTest('stats.distributions').run()



More information about the Scipy-svn mailing list