Skip to content

Fix von Mises-Fisher sampler #1930

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Fix von Mises-Fisher sampler #1930

wants to merge 5 commits into from

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Dec 16, 2024

Fixes #1423.

As already discussed in #1423, in the special case mu = [1, 0, ..., 0] no rotation of the "initial" sample is needed. I think skipping the rotation completely is preferable over a numerical workaround such as #1918.

I used the opportunity to also add comments and references to the existing code of the von Mises-Fisher sampler.

Edit: I switched to using LinearAlgebra.reflector! and LinearAlgebra.applyReflector!.

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.26%. Comparing base (bf4f03e) to head (022da79).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1930   +/-   ##
=======================================
  Coverage   86.26%   86.26%           
=======================================
  Files         146      146           
  Lines        8765     8769    +4     
=======================================
+ Hits         7561     7565    +4     
  Misses       1204     1204           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@williamjsdavis
Copy link

Nice work! This is an elegant solution, and I agree that it's preferable to the fix I proposed in #1918. I'm happy to delete that PR if/when this PR is accepted.

Copy link
Member

@andreasnoack andreasnoack left a comment

Choose a reason for hiding this comment

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

Can't we use the reflector machinery from LinearAlgebra instead of reimplementing it here. I.e. reflector! and reflectorApply!. I do realize that I did a poor job documenting the two, but the implementations should be robust and I think we avoid the rotate field.

@devmotion devmotion requested a review from andreasnoack March 30, 2025 21:57
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.

Sampling from von Mises Fisher yields NaN
4 participants