Skip to content

Conversation

@wouterwln
Copy link
Member

@wouterwln wouterwln commented Oct 22, 2025

Together with @esther-van-pelt . There are a couple of issues with the Multinomial distribution:

(1) The Fisher information, which I took from the wip folder implementation, returns non-invertible matrices. This is similar to what happens in Categorical, which makes sense because their functional form is really similar.
(2) logpartition is not differentiable for uniform Multinomial distribution. This is because of an optimization in logsumexp which renders it not differentiable by ForwardDiff.
(3) prod involves a sampling procedure, I did not want to take a dependency on StableRNGs so I used the builtin MersenneTwister to seed the random number generator.

@wouterwln wouterwln requested a review from ismailsenoz October 22, 2025 15:17
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 81.70732% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.28%. Comparing base (7326fe9) to head (a42dfc2).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/distributions/multinomial.jl 81.70% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   82.01%   84.28%   +2.26%     
==========================================
  Files          41       41              
  Lines        3409     3397      -12     
==========================================
+ Hits         2796     2863      +67     
+ Misses        613      534      -79     

☔ 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.

for n in 2:6
for trials in 2:10
@testset let d = Multinomial(trials, normalize!(rand(rng, n), 1))
test_exponentialfamily_interface(d; option_assume_no_allocations = false,
Copy link
Member

Choose a reason for hiding this comment

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

The PR is good. Only thing could you add some ad-hoc tests for the methods that we skipped to test in our generic test?

@wouterwln
Copy link
Member Author

@Nimrais could you add a test for mean parametrization Fisher information?

@Nimrais
Copy link
Member

Nimrais commented Oct 23, 2025

ok np

@ismailsenoz
Copy link
Collaborator

LGTM!! My only comment would be to use gamma and loggamma functions instead of factorial and logfactorial.

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.

5 participants