# $X|U=u\sim \mathsf{Unif}(0,u)$ and $U\sim\mathsf{Unif}(0,1):$ Are $X, U$ are independent?

Assume that $X$ and $U$ are two random variables such that:

$X|U=u \sim \mathsf{Unif}(0,u)$ and $U \sim \mathsf{Unif}(0,1)$

(1) Are $X$ and $U$ independent?

(2) Find $\mathsf E[X]$

Task (1) I'm having difficulties with this task since it's the only one of it's kind in my book.

So my idea is to use;

$X$ and $Y$ are independent if

$f_{XU}(x,u)=f_X(x)·f_U(u)$

Now since $U\sim\mathsf{Unif}(0,1)$ its PDF is given by:

$f_U(u)=1, u \in [0,1]$

Since $X|U=u \sim\mathsf{Unif}(0,u)$ its PDF is given by:

(First doubt arises here)

$f_{X|U}(x|u)=\frac{1}{u}, x \in [0,u]$

Having these I can rewrite this formula:

$f_{X|Y}(x|y)=\frac{f_{XY}(x,y)}{f_Y(y)}$

$f_{X|Y}(x|y)·f_Y(y)=f_{XY}(x,y)$

Thus;

$f_{XY}(x,y)=\frac{1}{u}·1$

To find the marginal PDF i integrate the above using $u's$ limits:

$\int_0^1\frac{1}{u}·1 du=0$

Now the above makes no sense. Something has gone wrong and hours of trying a lot of different things haven't solved it.

Task (2) Since I need the marginal PDF for $X$ to solve this I haven't solved it yet.

We are informed that $X\mid U\sim\mathcal U(0;U)$ and $U\sim\mathcal U(0;1)$.

We thus know for certain that $X<U$, so there is clearly dependency.

When given any knowledge about one you will gain knowledge about the other.   In particular: $$\forall x{\in}(0;1)~:~\mathsf P(X{>}x)>0~\land~ \mathsf P(X{>}x\mid U{\leq} x)=0$$

That is all you really need.

Anyway, by your proposed method you do correctly have the joint pdf:

$$f_{X,U}(x,u)~{=f_X(x\mid u)f_U(u)\\=\tfrac 1u \cdot\mathbf 1_{0<x<u<1}}$$

Since you have been given the distribution for $U$, so of course its marginal-pdf is: $$f_U(u)=\mathbf 1_{0<u<1}$$

But for the $X$ mariginal-pdf you should have (since $f_{X\mid U}(x\mid u)=0$ whenever $u\leqslant x$):

$$f_X(x) {= \int_\Bbb R f_{X\mid U}(x\mid u)f_U(u)\mathsf d u\\ = \left(\int_0^x 0~\mathsf du + \int_x^1 \tfrac 1u~\mathsf du\right)\cdot \mathbf 1_{0<x<1}\\=-\ln(x)\cdot\mathbf 1_{0<x<1}}$$

Always carefully consider the support.

PS: You do not need any of this for the second task.   Just make use of the Law of Iterated Expectation :

$$\mathsf E(X)~=~\mathsf E(\,\mathsf E(X\mid U)\,)$$

• I'm both impressed and thankful. Thank you for taking the time to explain the task in your own way, but also using my own method, despite it being a detour. Jan 10, 2018 at 9:35

Comment: The problem is not clear to me. My interpretation is that $X < U,$ so obviously not independent.

Here is a simulation in R statistical software that shows the connection between $X$ and $U$ that I have in mind.

If this is not what was intended, maybe you (or someone) can claify, and I will delete this.

m = 10^5;  u = runif(m); x = numeric(m)
for(i in 1:m) { x[i] = u[i] - runif(1, 0, u[i]) }  # define each x in terms of u
cor(x,u);  plot(u, x, pch=".")
## 0.6546795                    # x and u highly correlated
plot(u, x, pch=".")


The random variable $U$ is uniform; according to my interpretation, $X$ is not.

hist(x, br=40, prob=T, col="skyblue2")
curve(-log(x), add=T, col="blue", lwd=2, n=1001)


• Since already $X$ and $U$ are not independent, $X$ takes values ​​according to parameter $u$. For the calculation of the expectation, use the formula of the condional expectation. Jan 10, 2018 at 3:25
• @DanielCamarenaPerez. Thanks. I get $E(U/2) = 1/4$ and from the simulation mean(x) returns 0.2500259, which is within the margin of simulation error. // My 'Answer' was only to explore the issue of independence to clarify the meaning of the problem. Simulation is certainly not a real answer. Jan 10, 2018 at 4:58
• Now that @Graham Kemp has given a real Answer, I'll let it go. Jan 10, 2018 at 5:02
• Actually this is really helpful to me in general, since programming things in R is something I should get better at. It's a nice way for me to get ideas about a task. Please let the input stay here. It is much appreciated. Thank you for the input and thank you for taking the time to edit my question @BruceET Jan 10, 2018 at 9:39
• I patched the last figure to show the PDF of $X$ from Graham's excellent Answer. Glad you're learning some R along with probability. (But don't substitute simulation for analytic proofs--even if they do help make nice graphs.) Not everyone on the site is a fan of simulation, may take this down if it meets with disapproval. If you want the code, you might make a copy. Jan 10, 2018 at 9:51