Permalink
Browse files

BUG: incorrect limits in discrete ppf, fixes ticket:1802, see also ti…

…cket:1803
  • Loading branch information...
1 parent b69fe18 commit 804c17ff2e20521c2e94ced766a5e138d2303a3e @josef-pkt committed Jan 1, 2013
Showing with 13 additions and 3 deletions.
  1. +3 −3 scipy/stats/distributions.py
  2. +10 −0 scipy/stats/tests/test_distributions.py
@@ -5354,8 +5354,8 @@ def _drv2_moment(self, n, *args):
return tot
def _drv2_ppfsingle(self, q, *args): # Use basic bisection algorithm
- b = self.invcdf_b
- a = self.invcdf_a
+ b = self.b
+ a = self.a
if isinf(b): # Be sure ending point is > q
b = max(100*q,10)
while 1:
@@ -6661,7 +6661,7 @@ def _rvs(self, M, n, N):
def _argcheck(self, M, n, N):
cond = rv_discrete._argcheck(self,M,n,N)
cond &= (n <= M) & (N <= M)
- self.a = N-(M-n)
+ self.a = max(N-(M-n), 0)
self.b = min(n,N)
return cond
def _logpmf(self, k, M, n, N):
@@ -938,6 +938,16 @@ def test_norm_logcdf():
finally:
np.seterr(**olderr)
+def test_hypergeom_interval_1802():
+ #these two did not return in a reasonable time, if ever
+ assert_equal(stats.hypergeom.interval(.95, 187601, 43192, 757),
+ (152.0, 197.0))
+ assert_equal(stats.hypergeom.interval(.945, 187601, 43192, 757),
+ (152.0, 197.0))
+ #this was working also before
+ assert_equal(stats.hypergeom.interval(.94, 187601, 43192, 757),
+ (153.0, 196.0))
+
if __name__ == "__main__":
run_module_suite()

0 comments on commit 804c17f

Please sign in to comment.