And it also replaces the very crude Stirling's approximation with something more precise without depending on a ln_gamma implementation.
Details
I do not have evidence that the stirling errors effect sampling in a big way, but I also do not have evidence that they do not and the error is quite big for small values.
For performance reasons we could shift by less than 3, but the LOGSQRT2PI correction is cheap and helps already a lot. The 1/12v term might also not matter that much.
CHANGELOG.md
entrySummary
This is a fix for https://github.com/rust-random/rand/issues/1508 Thanks a lot to @WarrenWeckesser for finding it.
And it also replaces the very crude Stirling's approximation with something more precise without depending on a
ln_gamma
implementation.Details
I do not have evidence that the stirling errors effect sampling in a big way, but I also do not have evidence that they do not and the error is quite big for small values.
For performance reasons we could shift by less than 3, but the LOGSQRT2PI correction is cheap and helps already a lot. The 1/12v term might also not matter that much.