rand() functions producing pseudo-random numbers in [0,1] range

65 Views Asked by At

Reading the Wikipedia I stumbled at the List of random number generators.

It seems that all the effort in developing PRNGs went into generating uniform integers in some given range, let call it $[0, N]$.

If i want to get a "real" number in range $[0, 1]$, by using function rand() (e.g. in MATLAB), I internally generate an integer number in the above range $[0, N]$. Then the generated number is scaled down by $N$.

What makes me wonder, is that representable floating-point numbers (I suppose) are not uniformly dense in $[0, 1]$, i.e. I would expect that density of representable floating-point numbers is a decreasing function on $[0, \infty)$

Does this mean, that scaling down does not produce real numbers uniformly distributed in $[0, 1]$ ?

E.g., let say $\frac{1}{N}$ is exactly representable number, but $\frac{1,000,000}{N}$ is not, but there is a pretty close number $\frac{1,000,000}{N} - \varepsilon$ - so it will be picked by the scalling down process.