You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IteratorRandom::choose() uses a floating-point reciprocal to calculate probabilities. f64 reciprocal is an inexact operation with residuals on the order of 1 / 2^54.
For example: the probability of gen_bool(1.0 / 3) == true is: 6004799503160661/18014398509481984, which differs from 1/3 in the 17th digit.
An exact implementation of choose would be possible with gen_range.
The text was updated successfully, but these errors were encountered:
kazcw
added a commit
to kazcw/rand
that referenced
this issue
Oct 11, 2020
f64 reciprocal is inexact, with residuals on the order of 1 / 2^54.
For example: the probability gen_bool(1.0 / 3) == true is:
6004799503160661/18014398509481984
Using gen_range is exact for all values of `consumed`.
NOTE: this is a value stability-breaking change
fixesrust-random#1058
f64 reciprocal is inexact, with residuals on the order of 1 / 2^54.
For example: the probability gen_bool(1.0 / 3) == true is:
6004799503160661/18014398509481984
Using gen_range is exact for all values of `consumed`.
NOTE: this is a value stability-breaking change
fixesrust-random#1058
IteratorRandom::choose()
uses a floating-point reciprocal to calculate probabilities. f64 reciprocal is an inexact operation with residuals on the order of 1 / 2^54.For example: the probability of
gen_bool(1.0 / 3) == true
is: 6004799503160661/18014398509481984, which differs from 1/3 in the 17th digit.An exact implementation of
choose
would be possible withgen_range
.The text was updated successfully, but these errors were encountered: