-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
vonMises: Avoid overflow for large kappa #2832
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
Conversation
diverges might comes from funnel in the Real transformed space, looking at the Metropolis might not be very informative. |
@@ -931,6 +931,7 @@ def test_ex_gaussian(self, value, mu, sigma, nu, logp): | |||
pt = {'eg': value} | |||
assert_almost_equal(model.fastlogp(pt), logp, decimal=select_by_precision(float64=6, float32=2), err_msg=str(pt)) | |||
|
|||
@pytest.mark.xfail(condition=(theano.config.floatX == "float32"), reason="Fails on float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this not come up before? If the problem is scipy having overflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because, before both overflow. Now we can use vonmises with larger values of kappa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the feedback, one more thing @junpenglao. The only reason we have now i0 and i1 is to compute the variance when initializing the vonMises distribution. Should be remove them (and not compute the variance) or keep them? |
Is the current computation reliable? It is really quite minor and I doubt anybody is using it. So I would agree with removing it if the computation itself is also not very robust. |
pymc3/distributions/special.py
Outdated
@@ -3,7 +3,7 @@ | |||
from theano.scalar.basic_scipy import GammaLn, Psi, I0, I1 | |||
from theano import scalar | |||
|
|||
__all__ = ['gammaln', 'multigammaln', 'psi', 'i0', 'i1', 'log_i0'] | |||
__all__ = ['gammaln', 'multigammaln', 'psi', 'log_i0'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also remove the import from theano above.
log_i0
instead of log(i0) for computing vonMises' logp.Note: I still get some warnings about diverges (specially for kappa ~< 1). Despite these warnings the samples looks right compared against SciPy or sampling using Metropolis. I will see if I can fix this in a future PR.