Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scipy.stats.nbinom.logpmf(0,1,1) returns nan. Correct value is 0 #4029

Closed
pbrod opened this issue Sep 27, 2014 · 1 comment
Closed

scipy.stats.nbinom.logpmf(0,1,1) returns nan. Correct value is 0 #4029

pbrod opened this issue Sep 27, 2014 · 1 comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected good first issue Good topic for first contributor pull requests, with a relatively straightforward solution scipy.stats
Milestone

Comments

@pbrod
Copy link
Contributor

pbrod commented Sep 27, 2014

One solution is to replace _logpmf with:

def _logpmf(self, x, n, p):
    coeff = gamln(n + x) - gamln(x + 1) - gamln(n)
    return coeff + n*log(p) + special.xlog1py(x, -p)

Another issue is that according to wikipedia it is only defined for n>0, but here it is defined for n>=0.
Perhaps consider replacing _argcheck with

def _argcheck(self, n, p):
        return (n > 0) & (p >= 0) & (p <= 1)
@ev-br ev-br added scipy.stats defect A clear bug or issue that prevents SciPy from being installed or used as expected good first issue Good topic for first contributor pull requests, with a relatively straightforward solution labels Sep 28, 2014
@rgommers rgommers added this to the 0.15.0 milestone Nov 22, 2014
@rgommers
Copy link
Member

Fixed by gh-4049.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected good first issue Good topic for first contributor pull requests, with a relatively straightforward solution scipy.stats
Projects
None yet
Development

No branches or pull requests

3 participants