How to calculate the conditional mean of $E(X\mid X<Y)$?

In particular, $f(x,y)=1$ for $0<x<1$ and $0<y<1$. How to calculate the conditional mean of $E(X\mid X<Y)$?

I understand the conditional mean $E(X\mid Y) = \int_{-\infty}^{\infty}xf(x\mid Y)dx$. But how do we make sense of conditions like $X<Y$?


Solution 1:

Note that for any event $A$ $$\mathbb E[X\mid A]=\frac{\mathbb E[X\mathbf 1_{A}]}{\mathbb P(A)}.$$ Since $\mathbb P(X<Y)=\frac12$, $$\mathbb E[X\mid X<Y]=\frac{\mathbb E[X\mathbf 1_{X<Y}]}{\mathbb P(X<Y)}=2\mathop{\mathbb E}[X\mathbf 1_{X<Y}]=2\int_{y=0}^{y=1}\int_{x=0}^{x=y}x\,dx\,dy=\frac13.$$

Solution 2:

An empirical check of NCh's $[+1]$ solution using R statistical software.

x<-runif(10^5,0,1)
y<-runif(10^5,0,1)
z<-c()
for(i in c(1:(10^5)))
  if(x[i]<y[i]){z<-c(z,x[i])}
mean(z)

[1] 0.3338483

which is awfully close to $\frac{1}{3}$

Solution 3:

We have $$\mathbb{P}(X\leq a\mid X<Y)=\frac{\mathbb{P}(\{X\leq a\}\cap\{X<Y\})}{\mathbb{P}(X<Y)}.$$ The probability in the denominator can be calculated as $$\mathbb{P}(X<Y)=\int_{0}^{1}\int_{0}^{y}f(x,y)\,\mathrm{d}x\mathrm{d}y=\int_{0}^{y}\int_{0}^{1}f(x,y)\,\mathrm{d}y\mathrm{d}x=\int_{0}^{y}f(x)\,\mathrm{d}x=F_x(y),$$ where the idea is to fix a given $Y=y$ and integrate over all possible $X$ below that $y$, and then integrate over all possible values for the fixed $y$.
In the other hand, the numerator can be calculated as $$\mathbb{P}(\{X\leq a\}\cap\{X<Y\})=\int_0^a\int_0^yf(x,y)\,\mathrm{d}x\mathrm{d}y+\int_{a}^{1}\int_{0}^{a}f(x,y)\,\mathrm{d}x\mathrm{d}y,$$ where the last integral splits the probability in the case where $X\leq Y\leq a$ and when $X\leq a < Y$. The first integral says "if $Y\leq a$, X has to go only up to $Y$". The second says, "if $a<Y$, $X$ only has to go up to $a$". With these two calculations you obtain the CDF $F_{X\mid X<Y}$ and finally you calculate the expectation with respect to this CDF or Density, depending on how you decide to do it.

Edit: If we evaluate this, we get $$\mathbb{P}(X<Y)=\int_{0}^{1}\int_{0}^{y}f(x,y)\,\mathrm{d}x\mathrm{d}y=\frac{1}{2}$$ $$\mathbb{P}(\{X\leq a\}\cap\{X<Y\})=\int_0^a\int_0^y\,\mathrm{d}x\mathrm{d}y+\int_{a}^{1}\int_{0}^{a}\,\mathrm{d}x\mathrm{d}y,=\frac{a^2}{2}+a(1-a)$$ so $$F_{X\mid X<Y}(a)=\mathbb{P}(X\leq a\mid X<Y)=2a-a^2$$ and taking derivative to find the pdf we get $$f_{X\mid X<Y}(x)=2(1-x)$$ Therefore, the conditional expectation is $$\mathbb{E}(X\mid X<Y)=\int_0^1x f_{X\mid X<Y}(x)\mathrm{d}x=\int_0^1x 2(1-x)\mathrm{d}x=\frac{1}{3}$$