We produce a real number X through a two-stage experiment.

  1. First roll a fair die to get an outcome $Y\in\{1,2,...,6\}$.
  2. Then if $Y=k$, choose a point uniformly at random in $[0,k]$, denote it X.

What is the c.d.f. of X? What is the p.d.f. of X?

My Attempt:

The c.d.f. is defined as $F(t)=\mathbb{P}(X\leq t)$, so

\begin{equation} F(t)= \begin{cases} 0&\text{if } t<0\\ \frac{1}{6}\cdot\frac{1}{k-0}&\text{if }t\leq k\\ 1&\text{if } ??? \end{cases} \end{equation}

My thinking on how to get the probability is that there is a $\frac{1}{6}$ chance of rolling a number Y and then there is a $\frac{1}{k-0}$ chance of choosing a random number in $[0,k]$ because it is uniformly distributed. I am not sure what conditions of $t$ would cause a probability of $1$.

The p.d.f can be found by differentiating the c.d.f., but since there would be 6 different functions for $k\in\{1,2,...,6\}$, I am unsure how to combine them to differentiate. Should I sum them?

  • $\begingroup$ You have a mixture and your density is $f(x) = \pi_1 f_1(x) + \cdots + \pi_6 f_6(x)$ where $f_k$ is uniform on $[0, k]$. In this case since you have a fair die $\pi_1 = \cdots = \pi_6 = 1/6$. You're on the right track, it's just a matter of integrating. For $0 < x \leq 1$ you have contributions from all six uniform densities. The first will contribute $(\pi_1)(x / 1)$ and the second $(\pi_2)(x/2)$, etc. Then move on to $1 < x \leq 2$. $\endgroup$ Commented Feb 28, 2021 at 23:56

2 Answers 2


Here is a nice little diagram. The vertical bars divide the sections of the number line into regions corresponding to the weights (on the right).

0[6] 1                     6
0[3] |[3]2                 3 3
0etc.|   |  3              2 2 2
0    |   |  |  4           3/2 3/2 3/2 3/2
0    |   |  |  |  5        6/5 6/5 6/5 6/5 6/5
0    |   |  |  |  |  6     1 1 1 1 1 1

X will be uniform on each of these intervals given by the sum of the appropriate weights divided by 36, the sum of the weights. So for example, the pdf for X in the interval 0 and 1 is given by $\frac{6+3+2+3/2+6/5+1}{36}$. If you do this for each interval, you get the following pdf

$$f(X)=\begin{cases}49/120,&0<X<1\\ 29/120&1<X<2\\ 19/120&2<X<3\\ 37/360&3<X<4\\ 11/180&4<X<5\\ 1/36&5<X<6\end{cases}$$

This corresponds to the piecewise cdf with six intervals of straight lines of different slopes...

$$F(X)=\begin{cases}0&X<0\\ 49/120X,&0<X<1\\ 29/120(X-1)+49/120&1<X<2\\ 19/120(X-2)+13/20&2<X<3\\ 37/360(X-3)+97/120&3<X<4\\ 11/180(X-4)+41/45&4<X<5\\ 1/36(X-5)+35/36&5<X<6\\ 1&X>6\end{cases}$$

  • $\begingroup$ Do you mean X<6 for the last line of your cdf? $\endgroup$ Commented Mar 1, 2021 at 5:02
  • $\begingroup$ @JamesAnderson it should be X>6, because X is always less than 6. So F(6)=1, F(56)=1. In general, a cdf has value 1 at any value above the maximum possible value of the distribution. and has value 0 at any value below the minimum possible value. $\endgroup$
    – Vons
    Commented Mar 1, 2021 at 5:33
  • $\begingroup$ Can you explain how you found the weights? Thanks $\endgroup$ Commented Mar 1, 2021 at 6:10
  • $\begingroup$ @JamesAnderson By dividing the total number of sections per row by 6. $\endgroup$
    – Vons
    Commented Mar 1, 2021 at 6:26

Your computation of $F$ is wrong. There should not be any $k$ in $F(t)$.

$P(X \leq t)=\sum_{\{k: t \leq k\}} P(Y=k) \frac t k=\frac 1 6 \sum_{\{k: t \leq k\}} \frac t k$. [The sum is taken over $k$ such that $t \leq k$].

Now split this into the cases $0 \leq t \leq 1, 1<t\leq 2,...,5 <t \leq 6$. In the first case you get $f(t)=\frac 1 6 \sum\limits_{k=1}^{n} \frac t k$. In the second case you get $f(t)=\frac 1 6 \sum\limits_{k=2}^{n} \frac t k$, and so on. Now differentiate w.r.t. $t$ to find the density function of $X$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .