Avoid panic with almost-zero parameters for FisherF#39
Merged
dhardy merged 1 commit intorust-random:masterfrom Dec 2, 2025
Merged
Avoid panic with almost-zero parameters for FisherF#39dhardy merged 1 commit intorust-random:masterfrom
dhardy merged 1 commit intorust-random:masterfrom
Conversation
These are too small to construct a ChiSquared distribution from.
e39de18 to
bca62a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG.mdentrySummary
When
mornis a positive floating point value with0.5 m = 0.0(e.g. 1e-45 for f32, or 5e-324 for f64) the constructor of FisherF could panic in one of the unwrap() calls.Motivation
This is one of the unusual-parameter panics that I found by fuzzing, and fixing it turned out to be simple. (There's only a few more simple panics from fuzzing, and I expect fixing them before tackling the much trickier Binomial and Hypergeometric samplers may make things easier. And I'm not in a hurry :-). )
Details
The workaround is to reject FisherF distributions with
mornalmost zero instead of unwrapping. I expect that in practice people only use integralmandn.