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

Fix bug in SineBivariateVonMises sampler #1628

Merged
merged 2 commits into from
Aug 17, 2023

Conversation

deoxyribose
Copy link
Contributor

See https://cran.r-project.org/web/packages/simdd/index.html for R implementation.
Before fix, highly correlated distributions would fail to sample correctly, and max_sample_iter would exceed the default 1000, silently.
After fix, the same distribution sample correctly distributed values.

@@ -477,7 +477,7 @@ def update_fn(curr):
phi_key, key = random.split(key)
accept_key, acg_key, phi_key = random.split(phi_key, 3)

x = jnp.sqrt(1 + 2 * eig / b0) * random.normal(acg_key, shape)
x = 1./jnp.sqrt(1 + 2 * eig / b0) * random.normal(acg_key, shape)
Copy link
Member

Choose a reason for hiding this comment

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

nit: you can use jnp.rsqrt for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I made the edit.

Copy link
Member

@OlaRonning OlaRonning left a comment

Choose a reason for hiding this comment

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

Thanks @deoxyribose. This is indeed correct and consistent with the R implementation. Could you make a PR with the exact change here aswell.

@OlaRonning OlaRonning merged commit cc1ad02 into pyro-ppl:master Aug 17, 2023
4 checks passed
@OlaRonning OlaRonning deleted the sbvm-sampler-fix branch August 17, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants