This question already has an answer here:

For a non-negative real number $x$, write $Int(x)$ for the largest integer that is less than or equal to $x$. Let $U$ be a uniform random variable on $(0,1)$ and $n \geq 1$ an integer. Find the probability mass function of the (discrete) random variable $X = Int(nU) + 1$.

I don't really know how to start on this question, can someone please give me some hints?


marked as duplicate by Did, Stefan Hansen, Davide Giraudo, Asaf Karagila, Sasha Feb 19 '13 at 13:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ As a start, compute. Something modest like $n=3$ will tell you everything. $\endgroup$ – André Nicolas Feb 19 '13 at 7:26

We analyze in detail the case $n=3$. We will use the standard notation $\lfloor x\rfloor$ for what in the OP is called $\text{Int}(x)$.

(i) For $0\lt u\lt \frac{1}{3}$, we have $\lfloor 3u\rfloor +1=1$. So for these $u$, $X=1$.

(ii) For $\frac{1}{3}\le u\lt \frac{2}{3}$, we have $\lfloor 3u\rfloor +1=2$. So for these $u$, $X=2$.

(iii) Finally, for $\frac{2}{3}\le u\lt 1$, we have $\lfloor 3u\rfloor +1=3$. For these $u$, $X=3$.

Since the range of $U$ is $(0,1)$, $X$ can take on no values other than $1$, $2$, or $3$.

The probability that $X=1$ is the probability that $0\lt U\lt \frac{1}{3}$. Since $U$ is uniform on $(0,1)$, we conclude that $\Pr(X=1)=\frac{1}{3}$. The same sort of calculation shows that $\Pr(X=2)=\Pr(X=3)=\frac{1}{3}$.

Thus $X$ has the discrete uniform distribution on the set $\{1,2,3\}$.

A very similar analysis shows that for general $n$, your random variable $X$ has the discrete uniform distribution on the set $\{1,2,3,\dots,n\}$.

For general $n$, the random variable $X$ takes on the value $1$ if $0\lt u\lt \frac{1}{n}$, the value $2$ if $\frac{1}{n}\le u\lt \frac{2}{n}$, the value $3$ when $\frac{2}{n}\le u\lt \frac{3}{n}$, and so on. Each of these intervals has length $\frac{1}{n}$. In general, because $U$ has continuous uniform distribution on $(0,1)$, $U$ lands in any such interval with probability $\frac{1}{n}$.

Remark: The typical pseudo-random number generator simulates a continuous uniform distribution on $(0,1)$. By using the method described in this problem, we can use the pseudo-random number generator to simulate certain discrete uniform distributions. For example, by taking $n=6$, we can simulate the result of throwing a fair die.


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