# CDF for a random variable with random upper bound?

I am trying to calculate a CDF of a random variable $x$ which has an upper bound $z$, which is itself a random variable with distribution $G(z)$ on some interval $[z1,z2]$.

E.g. $x \sim U[0,z]$ and $z \sim U[1,2]$.

-
Welcome to MSE. Is this homework? If so, tag it as such. –  leonbloy Oct 3 '12 at 16:59
Hint: When you write x ~ U[0,z] you actually mean that, for a given value of $z$, $x$ is uniform in $[0,z]$. Which is to say that the conditional probability of $x$ is known. –  leonbloy Oct 3 '12 at 17:02
$f(x,z)=f(x|z)f(z)$. Integrate out $z$ and get marginal pdf of $x$. Then integrate to get CDF for $x$. –  Patrick Li Oct 3 '12 at 17:33
What this means, if it is to make any sense, is that the CONDITIONAL distibution of $x$ given $z$ is uniform on $[0,z]$. It's easy to neglect to say that, but it's worthwhile to be precise about it. People also often forget to mention independence where it's assumed. –  Michael Hardy Oct 3 '12 at 18:12
@TAK Yes, you are right that $f(x,z)=\frac{1}{z}$ but be careful about their supports. Since $0<x<z$ and $1<z<2$, the actual joint density is $f(x, z)=\frac{1}{z}\mathbb{I}[0<x<z]\mathbb{I}[1<z<2]$. –  Patrick Li Oct 3 '12 at 19:47

The conditional pdf of $X$ given $Z$ is $f(x|z)=\frac{1}{z}\mathbb{I}[0<x<z]$. The marginal pdf of $Z$ is $f(z)=\mathbb{I}[1<z<2]$. So the joint pdf of $X$ and $Z$ is $$f(x,z)=f(x|z)f(z)=\frac{1}{z}\mathbb{I}[0<x<z]\mathbb{I}[1<z<2]$$ Then we can integrate over $z$ and get $$f(x)=\int_{\max(x,1)}^{2} f(x,z)dz=\int_{\max(x,1)}^{2}\frac{dz}{z}=\log2-\log(\max(x,1))$$
You can proceed by integrating it to get the CDF of $X$. You need to consider two different conditions when $x > 1$ and $x < 1$.