3 ms·
See NextDoubleHighRes() here: https://github.com/colgreen/Redzen/blob/master/Redzen/Random/RandomSourceBase.cs https://github.com/colgreen/Redzen/blob/master/R
by redcalx 8y ago
See NextDoubleHighRes() here:
https://github.com/colgreen/Redzen/blob/master/Redzen/Random/RandomSourceBase.cs https://github.com/colgreen/Redzen/blob/master/Redzen/Random...
There's an explanation in the comments, and a link to the original fuller explanation and source, here:
https://mumble.net/~campbell/tmp/random_real.c https://mumble.net/~campbell/tmp/random_real.c
I.e. I'm pretty sure your approach gives a non uniform distribution, but happy to discuss in more detail if you want.
- FabHK 8y agoAmong the number it emits, the distribution is "uniform", but it leaves out many possible doubles (half between 0.5 and 1, a quarter between 0.25 and 0.5, etc.), as far as I understand. Great sources! (EDIT: replace "omit" by "leave out", because it's too close to "emit")
- redcalx 8y agoYeh that sounds right. Had forgotten the details as it's been a while since I went through all the issues and wrote and tested the redzen code.
- a1369209993 8y ago> your approach gives a non uniform distribution Unless I made some significant error, it is a uniform distribution over multiples of 2^-52. It's also a discrete approximation of the real uniform distribution in that for any subdivision of [0,1) into N equal (half-open) intervals, the most-populated interval has at most one more inhabitant the least populated one. It is however strictly inferior to rand53()*2^-53 (NextDoubleInner at your github link) unless your int64->double or float-multiply operations are quite bad.