4 ms·
That would violate #1, as it would generate numbers more frequently that lay in ranges of higher precision.
by ZoFreX 12y ago
That would violate #1, as it would generate numbers more frequently that lay in ranges of higher precision.
- Someone 12y agoBut you can't simultaneously have #1 and #2. #2 means that you pick a number between 1 and 2 as often as you pick one between 2 and 4, 4 and 8, etc. You can compensate for that by never returning many numbers, but that violates #2.
- danbruc 12y ago2) Generate numbers that meet the above definition AND so that any particular floating number is no more likely to be picked than any other. But you can't simultaneously have #1 and #2. #2 = #1 AND MORE and NOT (#1 AND #2) imply that #2 is impossible independent of #1 or MORE.
- art4711 12y agoYou most certainly can. If you follow the github links in that blog post, you'll see in arbitrary_range.c that that's exactly what I do in "rd_positive". Pick the highest number in the range, calculate the distance to next lower representable number, only return multiples of that (bounded by the total number of those distances within the range). For IEEE 754 doubles, unless your range can't represent that many doubles at all it makes you end up with somewhere between 52 and 53 bits of entropy per number generated.
- Someone 12y agoBut doesn't that mean that you decide to split he set of represent able numbers in gate range in those that your code can return and those that it will never return? Yes, the ones that you decide to return all have the same probability. The ones that you decide to never return have Rob ability zero. That is not "so that any particular floating number is no more likely to be picked than any other."
- SamReidHughes 12y agoIt's referring to the numbers that could be picked at all.
- ZoFreX 12y agoI made a mistake in my comment. It should say that any particular floating number is no more likely to be picked than any other with the same exponent. (I think that's right? So basically any representable number could be chosen, but ones in 'sparser' rangers will be more likely to be picked than a single number in a 'denser' range)