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.

Wrong results with hypergeom cdf

See original GitHub issue

The hypergeometric cdf gives wrong results with invalid parameters

Reproducing code example:

import numpy as np 
import scipy.stats as st 

print(st.hypergeom(M=3, n=3, N=4).pmf(np.arange(5))) 
print(st.hypergeom(M=3, n=3, N=4).cdf(np.arange(5)))                    
[nan nan nan nan nan]
[nan nan nan  1.  1.]

Scipy/Numpy/Python version information:

scipy = 1.5.4
numpy = 1.19.4
sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
WarrenWeckessercommented, Dec 22, 2020

I think a separate PR would be better.

1reaction
WarrenWeckessercommented, Dec 22, 2020

@tirthasheshpatel, that doesn’t look right. The same problem occurs with the public method support:

n [2]: hypergeom.support(1, 3, 4)
Out[2]: (6, 3)

I suspect a call to _argcheck needs to be incorporated into the support method of the rv_generic class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scipy.stats.hypergeom — SciPy v1.9.3 Manual
As an instance of the rv_discrete class, hypergeom object inherits from it a collection of generic methods (see below for the full list),...
Read more >
scipy.stats.hypergeom: Nan - Stack Overflow
1 Answer 1 ... You can't draw 24 objects from a collection whose total size is 6. The PMF is undefined in that...
Read more >
Multivariate Hypergeometric Cumulative Distribution Function
There's still a possibility that both of my approaches are wrong, but when two separate methods yield the same results it's promising. I...
Read more >
HYPGEOM.DIST function - Microsoft Support
Returns the hypergeometric distribution. HYPGEOM. ... DIST returns the cumulative distribution function; if FALSE, it returns the ... Description (Result).
Read more >
hypergeom
rv_null = st.hypergeom(M, n, N) x_null = np.arange(0, 40) pmf_null = rv_null.pmf(x_null) fig, ... Scipy's logcdf function returns non-sensical results:.
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