2 ms·
Wouldn't the best (and coincidentally simplest) way be to synthesize the double-precision word by combining a random integer exponent, a random integer mantissa
by CamperBob2 12y ago
Wouldn't the best (and coincidentally simplest) way be to synthesize the double-precision word by combining a random integer exponent, a random integer mantissa, and a random sign bit? You'd need to account for the logarithmic distribution of the exponent, but that seems like the biggest complication.
I don't understand the debate about rounding. What does it mean to round a random number? If the rounding process is biased, the number will be less random as a result, so you shouldn't have rounded it. If the process isn't biased, the number will be no more or less randomly-distributed than it was before, so there was no point in rounding it.
- alepper 12y agoThe clue's here: > What is the `uniform' distribution we want, anyway? It is obviously not the uniform discrete distribution on the finite set of floating-point numbers in [0, 1] -- that would be silly. For our `uniform' distribution, we would like to imagine[*] drawing a real number in [0, 1] uniformly at random, and then choosing the nearest floating-point number to it. Because of the logarithmic representation, there are as many floating point numbers between .25 and .5 as there are between .5 and 1. If you uniformly sample numbers with an exact, finite floating point representation then you don't get something that 'looks like' a uniform distribution of real numbers in [0, 1] -- which is more likely what was wanted.
- angersock 12y agoBingo. The ongoing mindfuck of floating point representations is that sort of non-even mapping of certain intervals.
- CamperBob2 12y agoRight, which is why I said you'd have to account for the log bias when you pick a random integer exponent. Otherwise most of your results would be really tiny. The method bhickey suggests above sounds like a nifty workaround for the problem as well.
- alepper 12y agoYou're right, sorry. I responded to 'why round?' but missed that comment.