BUG: Scipy stats probability greater than 1
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Fix has been merged into Boost.Math. Let me know if you need anything else.