Permalink
Browse files

Simplified code with a call to special.xlogy and special.xlog1py

  • Loading branch information...
1 parent 01b7092 commit 9cbe57b9dde47248ddaa034ae1b1397d3ec891cd @pbrod committed Mar 16, 2013
Showing with 1 addition and 3 deletions.
  1. +1 −3 scipy/stats/distributions.py
@@ -6605,9 +6605,7 @@ def _logpmf(self, x, n, p):
k = floor(x)
combiln = (gamln(n+1) - (gamln(k+1) +
gamln(n-k+1)))
- logp = where((p==0) & (k==0), 1, log(p))
- log1mp = where((p==1) & (k==n), 1, log1p(-p))
- return combiln + k*logp + (n-k)*log1mp
+ return combiln + special.xlogy(k,p) + special.xlog1py(n-k, -p)
def _pmf(self, x, n, p):
return exp(self._logpmf(x, n, p))
def _cdf(self, x, n, p):

0 comments on commit 9cbe57b

Please sign in to comment.