If I generate a random float value between 0…1, say to 40 digits, or n digits, aren't the chances of getting a true zero (0) or a true one (1) incredibly small? On the zero condition, every 0–9 digit has to be zero, and on the one condition, the first integer must be one and the rest should default to zero.

Does that logic of how a number is represented factor in to how random numbers are generated, or otherwise influence how unlikely that result is?

I don't have great insight into the scope of how random numbers are generated. If you ask, "What is your definition of a random number?" assume a generated digit could exhibit statistical randomness.

Part 2

If I generated numbers within a range, say 5…8, aren't all integer-value results [5,6,7,8] very unlikely as well?

Note: This whole question has no intended application; I am just curious. This question was partly influenced by the mathematical elaborations of ViHart on Youtube, specifically Proof some infinities are bigger than other infinities, and extra-specifically Cantor's diagonal argument.

P.S. If any moderators want to move this question elsewhere, that's okay with me!


Let's start from theory, and worry about "How To" later. Let's suppose that $U \sim \mathrm{Uniform}(0, 10)$. Now, fix an integer, say $i$. The probability that $i-\epsilon/2 < U < i+\epsilon/2$ is obviously $\epsilon$, for any $0 < \epsilon < 1$. Now, mathematical equality requires $\epsilon \to 0$, and so the probability of observing any integer is 0. But there was nothing magical about choosing an integer. The same is true for any constant in the support of $U$: $\pi$, $e$, $\phi$. It doesn't matter.

Now 0 is special (as is 10), because it forms one of the boundaries of the support of $U$, but it doesn't change the result in any way. The very definition of randomness requires that intervals of equal length have equal probability everywhere in the support.

Now, on to "how to". Knuth's extremely lucid discussion of random number generation in Volume 2 (Seminumerical Algorithms) of The Art of Computer Programming is still an excellent place to learn the basics. One of the things Knuth shows quite clearly is that it is much easier to generate pseudorandom numbers (PRN) badly than it is to generate them well. Intuition suggests that using a PRN generator as input to another should make things "better". Intuition is generally wrong. Generally speaking, PRN algorithms have to be pretty well-balanced in their parameter choices. (This is the problem with Excel's generator, by the way: decent algorithm, bad constants. That is almost more frustrating than a crappy algorithm to me, because the message it sends is, "We don't care.") There are lots of ways PRN generators can screw things up: serial correlation, short periods, non-uniform results, and the list goes on. To the extent that a given PRN generator is bad, it will fail to generate ensembles of values that conform to theory. Users should be aware that lots of bad PRN generators are still out there and in broad use.


In theory the probability that you get one specific number from a continuous probability distribution is 0, as the others already noted.

However, you mentioned "floats" and "random number generators", so I suspect you are interested in what is returned by a computer. A computer cannot store an infinite number of digits, as than storing such a number would take infinite memory. Instead it typically stores a number as a string of 23 (float) or 52 (double) 0s and 1s (it is a bit more complicated, but this gets at the main problem). This corresponds to about 7 and 16 digits in base 10. So on a computer an random number generator cannot generate a draw from a truely continuous variable, but from a discrete distribution. Often the "resolution" of a random number generator is even less than what is theoretically possible with float or double numbers.


The probability of any particular value being drawn from a continuous distribution is infinitely (more appropriately infinitesimally) small. One of the more theoretically-minded users here can probably check me on this, but I think it's because the corresponding event (i.e. the event that $X=x$ exactly) has measure zero in $\mathbb{R}$.

  • $\begingroup$ Yes, I think I can appreciate that any given point on a continuum is equally likely (or rather unlikely) to be the result of a single sample. Maybe that is all there is too it, I am the only thing that gives zero or one, or any integer, special meaning in a continuum. I think I needed some reinforcement to assert that giving zero and one any special meaning in a continuum of chance and that I shouldn't do so as they are all naturally as common. $\endgroup$ – ThorSummoner Jul 14 '14 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.