Bill Press
09-29-2009, 04:23 PM
When n*p>30, Binomialdev::dev() can return deviates that are >n, which should be impossible. In the worst case, with n~100, this happens as often as ~10^-4 of the time, and is a serious bug.
Fix: In Binomialdev::dev(), the line
if (k < 0) continue;
should be replaced by
if (k < 0 || k > n) continue;
Mathematically, this fix changes the returned distribution very slightly, in a machine-dependent way (depending on roundoff properties). We have verified that for the worst known case, the deviation from the true Binomial distribution is statistically undetectable in 10^9 calls. Thanks to stephan80 for finding it, and to davekw7x for his diagnosis.
Fix: In Binomialdev::dev(), the line
if (k < 0) continue;
should be replaced by
if (k < 0 || k > n) continue;
Mathematically, this fix changes the returned distribution very slightly, in a machine-dependent way (depending on roundoff properties). We have verified that for the worst known case, the deviation from the true Binomial distribution is statistically undetectable in 10^9 calls. Thanks to stephan80 for finding it, and to davekw7x for his diagnosis.