Expected value of a die given it is larger than another die I am exploring die problems for interview questions and I am struggling with this question
Given two 20 sided dice X and Y, what is E(X| X>Y)? A simulation and a proof here tells me that it should be 14. But when I try to solve it with law of total expectation, I get something else. Please tell me what I am doing wrong.
\begin{align*}
E(X | X>Y) & = \sum_{y=1}^{20} E(X|X>Y, Y=y) P(Y=y) \\
& = \sum_{y=1}^{20} E(X|X>y) \frac{1}{20} \\
&\text{There is no value > 20 so truncate the sum} \\
& = \sum_{y=1}^{19} E(X|X>y) \frac{1}{20} \\
&\text{The expectation of X is the average between y+1 and 20} \\
&= \frac{1}{20} \sum_{y=1}^{19} \frac{y+1+20}{2} \\
&= \frac{19*31}{40}
\end{align*}
Please help it is driving me insane!
 A: You have that
$$
\mathrm{E}[X|X>Y]=\frac{\mathrm{E}[X\mathbf{1}_{\{X>Y\}}]}{\Pr [X>Y]}=\frac{\int_{\Omega }X\mathbf{1}_{\{X>Y\}}dP}{\int_{\Omega }\mathbf{1}_{\{X>Y\}}dP}=\frac{\int_{\{(s,t):s>t\}}sF_{X,Y}(d(s,t))}{\int_{\{(s,t):s>t\}}F_{X,Y}(d(s,t))}\tag1
$$
where $F_{X,Y}$ is the joint distribution of $X$ and $Y$. As $X$ and $Y$ represent dice we can assume that $X$ and $Y$ are independent, therefore $F_{X,Y}=F_X\cdot F_Y$, and as $X$ and $Y$ are discrete random variables with support in $C:=\{1,2,\ldots ,20\}$ we can write
$$
F_{X,Y}(d(s,t))=F_X(ds)\otimes F_Y(dt)=(p_X(s)\delta s)\otimes (p_Y(t)\delta t)\\
=p_X(s)p_Y(t) \delta s\otimes \delta t=\frac1{20}\mathbf{1}_{C}(s)\frac1{20}\mathbf{1}_{C}(t)\delta s\otimes \delta t\tag2
$$
where $\delta s\otimes \delta t$ is the counting measure in $\mathbb{Z}^2$ and $p_Z=\frac1{20}\mathbf{1}_{C}$ is the probability mass function of a fair dice $Z$ of twenty sides. Then from all of the above we can simplify the notation using sums, giving
$$
\mathrm{E}[X|X>Y]=\frac{\sum_{(s,t)\in I}s}{\sum_{(s,t)\in I}1}\tag3
$$
for $I:=\{(s,t)\in C^2: s>t\}$. Now the difficult part is write $\sum_{(s,t)\in I}=\sum_{s\in I_1}\sum_{t\in I_2}$ for two sets $I_1,I_2 \subset  \mathbb{Z}$. However, its easy to see that fixing a value for $s$ then the range of $t$ is $\{1,\ldots ,s-1\}$, as it must be the case that $t\in C$ and $t<s$, thus we find that $I_1=C$ and $I_2=\{1,\ldots ,s-1\}$, where we assume that $I_2=\emptyset $ if $s-1\leqslant 0$. Then
$$
\sum_{(s,t)\in I}s=\sum_{s=1}^{20}s\sum_{t=1}^{s-1}1=\sum_{s=2}^{20}s(s-1)=\frac{s^{\underline{3}}}{3}\bigg|_2^{21}=\frac{21^{\underline{3}}}3\\
\sum_{(s,t)\in I}1=\sum_{s=2}^{20}(s-1)=\sum_{s=1}^{19}s=\frac{s^{\underline{2}}}{2}\bigg|_1^{20}=\frac{20^{\underline{2}}}{2}\\
\therefore\quad \mathrm{E}[X|X>Y]=\frac{2}{3}21=14
$$
where the notation $a^{\underline{k}}$, for some $k\in \mathbb{Z}$, represents a falling factorial.
