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

Vonmisesfix #4649

Merged
merged 2 commits into from Mar 20, 2015
Merged

Vonmisesfix #4649

merged 2 commits into from Mar 20, 2015

Conversation

aarchiba
Copy link
Contributor

The von Mises distribution CDF doesn't work properly for narrow distributions because the exponential and the Bessel function it is divided by both underflow; scipy.special.i0e exists for this very reason. Wrote a test and fixed the problem.

argriffing added a commit that referenced this pull request Mar 20, 2015
@argriffing argriffing merged commit 4f41d3a into scipy:master Mar 20, 2015
@argriffing
Copy link
Contributor

Thanks, merged!

@ev-br ev-br added scipy.stats defect A clear bug or issue that prevents SciPy from being installed or used as expected labels Mar 20, 2015
@ev-br ev-br added this to the 0.16.0 milestone Mar 20, 2015
@@ -30,7 +30,7 @@ cdef double von_mises_cdf_series(double k,double x,unsigned int p):
return 0.5 + x / (2 * NPY_PI) + V / NPY_PI

cdef von_mises_cdf_normalapprox(k, x):
b = sqrt(NPY_2_PI) * np.exp(k) / i0(k)
b = sqrt(NPY_2_PI) / i0e(k) # Check for negative k
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this comment mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea is that the new code is not equivalent to the old code when k is negative, because an absolute value is taken. But for the Von-Mises distribution k must be non-negative anyway so it's OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is checked somewhere else in the stats infrastructure then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the comment can go - you only get to this branch if k>50. But in fact the von Mises distribution does make sense for k<0 (same as that for -k but shifted by pi), and this is not really implemented in scipy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be? That seems like a relatively straightforward change.

@josef-pkt
Copy link
Member

docstrings would be nice to know what k and x are

kappa is the dispersion shape parameter for vonmises, AFAIR, and should be > 0 by default argument checking in the distribution

@aarchiba aarchiba deleted the vonmisesfix branch March 20, 2015 17:48
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 scipy.stats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants