Say there is a random variable X which can take 3 values 1,2,3 with equal probability. The task is to draw realizations from this random variable.

Any simple textbook will say consider a realization as 1 if you get a realization from Uniform distribution as less than, 0.33, and as 2 if you get a realization from Uniform distribution as less than, 0.66 (and more than 0.33), and otherwise 3.

This is okay, however, I could not understand the logic of it. I understand that logically it is somehow related to the fact that the CDF of all random variable has a uniform distribution, however, I could not establish the link between above drawing policy and this CDF's distributional theory.

Could somebody please explain this to me in an intuitive way?


2 Answers 2


Michael has given you the intuitive explanation - I'll try to give you the mathematical dito.

As you mentioned, if $X$ is a random variable and $F(x)$ is its cdf, then $F(X)\sim U(0,1)$. Let $F^{-1}$ be the inverse of $F$, so that $F^{-1}(F(X))=X$. (For now, we just assume that such a function exists. More about that later...)

If $Y\sim U(0,1)$, so that $F(X)$ and $Y$ have the same distribution, then $F^{-1}(Y)$ has the same distribution as $X$: $$P\Big(F^{-}(Y)\leq u\Big)=P\Big(F^{-}(F(X))\leq u\Big)=P\Big(X\leq u\Big).$$ This means that if $y$ is a realization of $Y$ then $F^{-}(y)$ can be viewed as a realization of $X$.

For a continuous random variable, $F$ is increasing and continuous and simple to invert. For a discrete random variable, $F$ is an increasing step function and we can use the generalized inverse $F^{-}$ instead: $$F^{-}(z)=\sup \{x: F(x)\leq z\}.$$

In your case you have three equiprobable outcomes $1,2,3$, so $$F(z)=\begin{cases}0\qquad\mbox{if}\quad z< 1,\\ 1/3\qquad\mbox{if}\quad 1\leq z<2,\\ 2/3\qquad\mbox{if}\quad 2\leq z<3,\\ 1\qquad\mbox{if}\quad z\geq 3,\\ \end{cases}$$ which means that $$F^{-}(y)=\begin{cases}1\qquad\mbox{if}\quad y\leq 1/3,\\ 2\qquad\mbox{if}\quad 1/3<y\leq 2/3,\\ 3\qquad\mbox{if}\quad2/3< y\leq 1. \end{cases}$$

To generate a realization of $X$, generate a $U(0,1)$ variable $Y$ and take $F^{-}(Y)$. This gives the rule described in your question.


It is not really all that complicated and you don't have to think of it in terms of the cdf (probability integral transformation). If you divide the unit interval into three equal length regions and assign a 1 for one region, a 2 for a second and 3 for the third then the probability will be 1/3 each for drawing 1, 2 and 3. The choice of which number to assign to a particular region can be arbitrary.


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.