Find the CDF and PDF of X We produce a real number X through a two-stage experiment.

*

*First roll a fair die to get an outcome $Y\in\{1,2,...,6\}$.

*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?
 A: 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}$$
A: 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$.
