Skip to content

Replace gamma_distribution to fix FP exceptions

Erik Lindahl requested to merge 3234-gammadistribution-fpe into release-2021

Our previous gamma distribution random numbers based on libcxx could cause FP exceptions in rare circumstances when an underlying uniform distribution retured exactly 0.0. To fix this, gamma_distribution has been replaced with an implementation based on Marsaglia & Tsang, which also appears to be used in a number of other libraries. The unit tests have also been expanded to explicitly test all three paths for alpha (below 1, 1, or over 1), and we have clarified the documentation about the role of the two parameters as well as added tests for them.

Closes #3234 (closed)

Merge request reports