# Let. $X \sim \mathcal{U}(0,1)$. Given $X = x$, let $Y \sim \mathcal{U}(0,x)$. How can I calculate $\mathbb{E}(X|Y = y)$?

Suppose that $X$ is uniformly distributed over $[0,1]$. Now choose $X = x$ and let $Y$ be uniformly distributed over $[0,x]$. Is it possible for us to calculate the "expected value of $X$ given $Y = y$", i.e., $\mathbb{E}(X|Y = y)$?

Intuitively, it seems that if $y = 0$, we gain no information, and so $\mathbb{E}(X|Y = 0) = \mathbb{E}(X) = \dfrac{1}{2}$, and also that if $y = 1$, it must be the case that $x = 1$, so $\mathbb{E}(X|Y = 1) = 1$. I don't know if this reasoning is correct, but if it is, then it seems to suggest that $\mathbb{E}(X|Y = y)$ should be a monotonic function of $y$ over $[0,1]$, increasing from $\dfrac{1}{2}$ to $1$.

I can also try to do some calculations with probability densities. From the statement of the problem, we have $f_X = 1$ and $f_{Y|X} = \dfrac{1}{x}$. Now, the joint distribution is $f_{XY} = f_X f_{Y|X} = \dfrac{1}{x}$, and as a sanity check we can verify that indeed $\displaystyle\int_0^1 \int_0^x \dfrac{1}{x} \,\mathrm{d}y \,\mathrm{d}x = 1$.

Now it seems to me that $\displaystyle f_Y = \int_y^1 f_{XY} \,\mathrm{d}y = -\ln(y)$, and so we can do the following calculation:

$$f_{X|Y} = \frac{f_{Y|X} f_X}{f_Y} = -\frac{1}{x \ln y}.$$

Now, I thought that I would be able to perform the following calculation to arrive at my result:

$$\mathbb{E}(X|Y = y) = \int_y^1 -\frac{1}{x \ln y} \cdot x \,\mathrm{d}x = \frac{y-1}{\ln y}.$$

Is this right? If not, where have I gone wrong?

• Why this certainly doesn't seems right ? – Nizar Apr 12 '16 at 7:27
• @Nizar: Okay, hmm, maybe it's right -- I'm not so sure about my intuition that the expected value must be bounded below by $1/2$ anymore. It doesn't make sense to say that getting $y = 0$ provides zero information! I think... – Marcus Emilsson Apr 12 '16 at 7:30
• When y = 1, your $\mathbb{E}[X | Y = y] = 0$. That's not right. I am wondering why are you integrating from y to 1, instead of 0 to y for both $f_Y$ and $\mathbb{E}[X|Y = y]$? – TenaliRaman Apr 12 '16 at 8:37
• @TenaliRaman $\mathsf E(X\mid Y=1)= \lim\limits_{y\to 1^+}\frac{y-1}{\ln y}=1$. That is okay. The integration wrt $x$ is over $(y;1)$ because $0\leq Y\leq X\leq 1$. – Graham Kemp Apr 12 '16 at 9:57
• @GrahamKemp You are right, thanks. – TenaliRaman Apr 13 '16 at 13:14

Everything is correct, except your intuition, which is only partially right: $E[X|Y=0]=0$, not $1/2$. In fact, the smaller $Y$ is, the more likely $X$ is to be small. More precisely, the conditional density of $X$ at $x$ given $Y=y$ is proportional (by Bayes) to that of $Y$ at $y$ given $X=x$, that is, to $1/x$. And since $1/x$ integrates to infinity on $[0,1]$, we get that the conditional density of $X$ converges, as $y\to0$, to the delta function at $0$.