Are there many fewer rational numbers than reals?

Intuitively, think that the rational numbers have a periodic decimal representation. If you draw a number digit by digit, what are your chances to make a periodic drawing compared to a completely random one ?


At risk of over-complicating things, if you dig a little deeper you'll find that your professor defines "uniform distribution" to mean that for any subset $S$ of $[0,1]$, the so-called "probability of drawing a number in $S$" is the Lebesgue measure of the set $S$.

If you don't know the real definition, you can think of the Lebesgue measure of $S$ as being the area under the graph of the characteristic function of $S$, that is to say the function that takes value $1$ for elements in $S$ and $0$ elsewhere. It might be that your professor would state his definition in terms of lengths or integrals rather than Lebesgue measure as such, but it will amount to the same thing.

Now, it turns out that that rational numbers are countable, and that the Lebesgue measure of any countable set in the real numbers is $0$. Hence, the probability is $0$ directly from the way he defined his distribution in the first place.

You need a certain amount of mechanism to define Lebesgue measure formally and show that the measure of any countable set is $0$, but the general idea is as follows. Consider a countable sequence of points $a_i$. For any given small number $\epsilon > 0$, we can put an interval of size $\frac{\epsilon}{2}$ around the first point $a_1$, an interval of size $\frac{\epsilon}{4}$ around $a_2$, and in general size $\frac{\epsilon}{2^i}$ around $a_i$. The intervals overlap, but the sum of the lengths of all of them is $\epsilon$, so the measure of their union is no greater than $\epsilon$, which recall can be as small as we like. This means the set $\{a_i: i \in \mathbb{N}\}$ can be contained in as "short" a set of intervals as we like, which (once we make a suitable set of formal definitions) means it has measure $0$ and intuitively it means the set of rationals "has no length" in the reals, and occurs with probability $0$. The complement of the rationals, the set of irrational numbers, cannot be covered in arbitrarily small intervals this way, and doesn't have measure $0$ (in fact it has measure $1$, which is good news for people who want their probabilities to add up!)

There are plenty of probability distributions on $[0,1]$ that aren't continuous, and for which your professor's statement isn't true. I presume he means the continuous uniform distribution because that's always the distribution people mean when they don't bother to state it, but the property does hold for any continuous distribution, so he's not out of order to leave off the details.


All of the answers here presume that your [0, 1] denotes a subset of the Real Numbers, but you said,

Well, this lesson is called "Introduction to Computers"

Computers do not use Real Numbers. If [0, 1] denotes the set of numbers that could be returned by a random number generator (procedure) in a computer program, then the probability of getting a rational result from it is 1.

Every floating-point number is rational.