Output distribution of rand(Float32) and rand(Float64), thread 2

Right, so then it’s even slower yet. Tradeoffs, people. A better fixup is to map those 1s to 0s (edit: I think?); your solution has zeros as being half as likely as they should be. But it’s still papering over a rounding issue that makes even Float32s ever-so-slightly more likely in the output (sure, it’s on the order of 2^-29, but it’s the kind of thing an RNG could — and should — get right).

This is why I call this the work of magicians and have been (perhaps overly) critical here. There’s so many ways you can get RNGs wrong.

2 Likes