3 ms·
At first, I thought trying to sample "uniformly" from a discrete non-homogeneous set of real numbers was just mathematically nonsense, but there's actually a pr
by evanpw 12y ago
At first, I thought trying to sample "uniformly" from a discrete non-homogeneous set of real numbers was just mathematically nonsense, but there's actually a pretty elegant generalization:
Basically, the probability of picking any particular floating-point value x should be proportional to the distance from x to the next largest representable number (with zero probability of choosing the largest floating-point number). This has the property that for any two floating-point numbers a and b, the probability of sampling a value in the interval [a, b) is proportional to b - a, which is the same as the defining property of the usual uniform distribution on real numbers, just with some additional restrictions.