Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Fix von Mises-Fisher sampler

Open devmotion opened this issue 11 months ago • 2 comments

Fixes https://github.com/JuliaStats/Distributions.jl/issues/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!.

devmotion avatar Dec 16 '24 23:12 devmotion

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 86.36%. Comparing base (bbdd4f1) to head (e6bc07c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1930   +/-   ##
=======================================
  Coverage   86.35%   86.36%           
=======================================
  Files         146      146           
  Lines        8782     8786    +4     
=======================================
+ Hits         7584     7588    +4     
  Misses       1198     1198           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov-commenter avatar Dec 16 '24 23:12 codecov-commenter

Nice work! This is an elegant solution, and I agree that it's preferable to the fix I proposed in https://github.com/JuliaStats/Distributions.jl/pull/1918. I'm happy to delete that PR if/when this PR is accepted.

williamjsdavis avatar Feb 05 '25 05:02 williamjsdavis

I'm merging this PR, based on the tests it seems to be a clear improvement. We can iterate further if someone notices additional problems.

devmotion avatar Oct 22 '25 18:10 devmotion

Seems every PR requires approval before it can be merged.

devmotion avatar Oct 23 '25 10:10 devmotion