# Why is it possible to generate a random real from the uniform distribution, but not a random rational from an equivalent distribution??

Why is it possible to generate a random real from the uniform distribution, but not a random rational or algebraic number from a distribution with similar properties?

• Do you understand why we can't uniformly sample $\Bbb Z$? Can you see why the same logic applies to $\Bbb Q$, or $\Bbb Q\cap[0,\,1)$ for that matter?
– J.G.
Commented Jul 10 at 9:05
• There is no uniform distribution on a countably infinite set since for mutually exclusive events you have $P\left(\bigcup\limits_{i = 1}^\infty E_i\right) = \sum\limits_{i=1}^\infty P(E_i)$: if all the $P(E_i)$ were equal, you would either get a total probability of $0$ or get $\infty$ when it should be $1$. Commented Jul 10 at 9:07
• I do understand, but my question is about the reals. Why is it possible in the reals? Commented Jul 10 at 9:23
• It's not unless you're referring to Bayesian improper priors. If you're not, then you have to specify a finite range for your distribution. Commented Jul 10 at 11:00

Let's assume $$A$$ is some subset of the real interval $$[0,1]$$. We have 3 cases:
1. $$A$$ is finite, $$|A| =n$$. Then we can have a uniform probability for any $$x\in A$$: $$P(x)=1/n$$. In this way, $$P(X \in A) = \sum_{x\in A} P(x) = 1$$ and we are fine.
2. $$A$$ is countably infinite. Then either $$P(x)=0$$ or $$P(x)=\epsilon >0$$. But in the first case $$P(X \in A) = \sum_{x\in A} P(x) = 0$$ (no good) and in the second case $$\sum_{x\in A} P(x) = \infty$$ . So in neither case we can build a uniform probability.
3. $$A$$ is infinite not countable. In this case we might have $$P(x)=0$$ but still $$P(X \in A)=1$$ because the total event cannot be descomposed as a countable union, which would result in countable sum of zero probabilities. This is the case of the $$A=[0,1]$$ using the standard measure.