# Distribution of a uniform random variable with random endpoint

Let $Y \sim U[0,k]$, where $0 < k < \infty$ and $U$ is a continuous uniform distribution. Now let $X \sim U[0, Y]$. What is the distribution of $X$? Is it possible to express in terms of some well-known distribution?

-
Are you sure $k$ is not bounded from above? You may have some convergence problems. – baudolino Apr 8 '14 at 16:14
Thank you, I've changed the question to reflect this. – schme Apr 8 '14 at 16:20
I'd write "$X\mid Y\sim U(0,Y)$". ($X\mid Y$, not to be confused with $X|Y$, but that's just a typographical point.) – Michael Hardy Apr 8 '14 at 16:31
The change in the posting from $k>0$ to $0<k<\infty$ is really no change at all. But I don't see how "convergence problems" result from $k$ being arbitrarily large. – Michael Hardy Apr 8 '14 at 16:33

For $0<x<k$, \begin{align} \Pr(X\le x) & = \mathbb E(\Pr(X\le x \mid Y)) \\[12pt] & = \mathbb E \left.\begin{cases} \dfrac x Y & \text{if }Y>x \\[8pt] 1 & \text{if }Y<x \end{cases}\right\} = 1\Pr(Y<x) + \mathbb E\left(\frac x Y\mid Y>x\right)\Pr(Y>x) \\[10pt] & = \frac x k + \frac{k-x}{k}\int_x^k \frac x y \, \frac{dy}{k-x} \\[10pt] & = \frac x k + \frac{x}{k} \int_x^k \frac{dy}{y} = \frac x k\left(1 + \log_e \frac k x \right). \end{align}
The density is therefore the derivative of that: $$\frac{-1}{k}\log_e \frac x k \text{ for }0<x<k\text{ (and 0 for }x<0\text{ or }x>k).$$