question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Scipy stats probability greater than 1

See original GitHub issue

Describe your issue.

I am computing values of a binomial probability mass function and find that their sum exceeds 1 when passing extreme parameters to the pmf. stackoverflow question. No error is thrown, meaning the problem could easily go unnoticed.

Reproducing Code Example

from scipy.stats import binom
n = 1541096362225563.0
p = 1.0477878413173978e-18
vals = [binom.pmf(n=n, p=p, k=i) for i in range(3)]
print(vals)  # -> [0.9983865609638467, 1.0, 0.060730098812886574]

Error message

.

SciPy/NumPy/Python version information

1.5.3 1.18.5 sys.version_info(major=3, minor=6, micro=9, releaselevel=‘final’, serial=0)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mborlandcommented, Oct 16, 2022

See: https://github.com/boostorg/math/pull/847.

I used @mdhaber suggested test values, and now we have the correct values and a sum <= 1.

1reaction
mborlandcommented, Oct 18, 2022

Fix has been merged into Boost.Math. Let me know if you need anything else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scipy stats probability greater than 1 - python - Stack Overflow
For such extremely small p and extremely large n I'd suggest trying a Poisson approximation to the binomial, where the rate λ is...
Read more >
Statistics (scipy.stats) — SciPy v1.9.3 Manual
Let's check the number and name of the shape parameters of the gamma distribution. (We know from the above that this should be...
Read more >
The dirichlet distribution unnecessarily rejects probabilities ...
I think that there is a bug in scipy.stats: the dirichlet ... but the issue remains that x can be zero if alpha...
Read more >
Distributions
The probability distribution (for a fair dice) is constant: 1/6; Scipy.stats documentation on discrete statistical distributions. Continuous.
Read more >
Some Basic Statistics - Jupyter Notebooks Gallery
One -way analysis of variance (ANOVA); Student's t-test; F-test; Coefficient of determination; Pearson's correlation coefficient; Probability Distribution ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found