Skip to content

Conversation

@mstoeckl
Copy link
Contributor

@mstoeckl mstoeckl commented Dec 11, 2025

  • Added a CHANGELOG.md entry

Summary

This introduces a file in distr_test to add tests focused on detecting cases where a distribution sampler is biased on a particular event.

Motivation

Some of the distribution sampling issues that I have found are hard to discover with a Kolmogorov-Smirnov or similar general distribution test, because the issues only occur with large input parameters or low probabilities, and would require a lot of time and memory to detect with a general test.

This is marked as draft for now, as the changes are still a bit rough.

Details

The last bit tests systematically confirm that the floating point precision issue for Binomial indeed only occurs at n > 2^53; and that the Geometric sampler has no equivalent issue.

test_binomial_endpoints can be used to confirm that the change in endpoint rounding for the BTPE method in #43 is reasonable -- currently the probability of 0 or 20 being sampled is ~50% higher than expected on Binomial(20, 0.5), while with #43 the event does not occur at a rate clearly distinguishable from the ideal probability.

Since rand_distr reexports Bernouilli, it may as well have a distribution test for it.

Directly testing that the probability of an event is as expected
can be considerably more powerful and can require less memory
than performing a Kolmogorov-Smirnov test; however, this approach
is much less flexible.
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.

1 participant