Derivative of the maximum of two random variables For any two real numbers $a$ and $b$ and any two random variables (with no mass points in their distributions) $x$ and $y$, why is it that the derivative of $E[\max\{a+x,b+y\}]$ with respect to $a$ is $\Pr(a+x>b+y)$?
 A: Use the law of total expectation:
\begin{align}
& \lim_{\Delta a\to0}\frac{\operatorname E(\max\{a+\Delta a+x,b+y\}) - \operatorname E(\max\{a+x,b+y\})}{\Delta a} \\[10pt]
= {} & \operatorname E \left(\lim_{\Delta a\to0}\frac{ \max\{a+\Delta a+x,b+y\} - \max\{a+x,b+y\}}{\Delta a}\right) \\[10pt]
= {} & \operatorname E\left( \operatorname E\left( \left.\lim_{\Delta a\to0}\frac{ \max\{a+\Delta a+x,b+y\} - \max\{a+x,b+y\}}{\Delta a} \,\right|\, I \right)\right)
\end{align}
where
$$
I = \begin{cases} 0 & \text{if }\max\{a+x,b+y\} = b+y \\[8pt] 1 & \text{if } \max\{a+x,b+y\} = a+x  \end{cases}
$$
If $b+y$ is the maximum, then the conditional expected value is $0$.
If $a+x$ is the maximum, then the conditional expected value is $1$.
So the outer expected value is the expected value of a random variable that is $1$ with probability equal to $\Pr(a+x>b+y)$ and $0$ with the complementary probability.
A: Warning: The statement is not true as you have asked it. We will only be able to show that the derivative exists at points $a$ where $P[a+x=b+y]=0$. I give a counterexample below for when this condition is not met.
Let $|h_n| \downarrow 0$. Consider that for all $\omega \in \Omega,$ for all $n$ large (depending on $\omega$), we will have have $$\max\{a+h_n+x(\omega),b+y(\omega)\}-\max\{a+x(\omega),b+y(\omega)\} $$
$$
= \left\{\begin{array}{cc}
h_n, & a+x(\omega)>b+y(\omega)\\
0,&  a+x(\omega)< b+y(\omega)\\
h_n 1_{h_n>0},&a+x(\omega)=b+y(\omega)
\end{array} \right.
$$
Thus the difference quotient satisfies
$$
\lim_{n \to \infty} \frac{1}{h_n}(\max\{a+h_n+x(\omega),b+y(\omega)\}-\max\{a+x(\omega),b+y(\omega)\} ) = 1_{a+x(\omega) > b+y(\omega)}
$$
for all $\omega$ where $a+x(\omega)\neq b+y(\omega)$.
We see that the derivative will exist at $a$ if $P(a+x=b+y)=0$ by taking expectations and applying dominated convergence (the difference quotients are bounded!).  Doing so gives $$\partial_a E[\max\{a+x,b+y\}] = E[1_{a+x > b+y}] = P[a+x > b+y].$$
Note that we did not need independence of $x$ and $y$.
Example of the derivative not existing if $P[a+x = b+y]>0$. Take a fair 2-coin flip space, with $x$ being the indicator of the first flip being heads and $y$ being the indicator of the second flip being heads. Take $a=b=0$. Of course $P[x=y]=\frac12$.
Then the difference quotient turns out to look like
$$
\frac{\max (0,h)+\max (0,h+1)+\max (1,h)+\max (1,h+1)-3}{4 h}
$$
$\hskip 1.5 in$
as function of $h$.
In fact,

Expectation[
   Max[x + a, y], {Distributed[x, BernoulliDistribution[1/2]], 
    Distributed[y, BernoulliDistribution[1/2]]}]

gives
$$
\frac{1}{4} (\max (0,a)+\max (0,a+1)+\max (1,a)+\max (1,a+1))
$$
which looks like
$\hskip 1.5 in$
Thus the derivative does not exist for $a=0$.
A: Assume first that $b=0$ and that $x=0$ almost surely, and let $u(a)=E(\max(a,y))$. The identity $\max(a,y)=y+(a-y)^+$ and the fact that $a\mapsto(a-y)^+$ is differentiable to the right with derivative $a\mapsto\mathbf 1_{a\geqslant y}$ and differentiable to the left with derivative $a\mapsto\mathbf 1_{a\gt y}$ show that $u$ is differentiable to the right with derivative $a\mapsto\mathbb P(a\geqslant y)$ and differentiable to the left with derivative $a\mapsto\mathbb P(a\gt y)$.
In the general case, start from the identity $\max(a+x,b+y)=x+\max(a,b+y-x)$ and use the case above with $b+y-x$. Thus, the function $a\mapsto E(\max(a+x,b+y))$ is differentiable to the right with derivative $a\mapsto\mathbb P(x+a\geqslant b+y)$ and differentiable to the left with derivative $a\mapsto\mathbb P(x+a\gt b+y)$.
Finally, the function $a\mapsto E(\max(a+x,b+y))$ is differentiable exactly at the points $a$ such that $\mathbb P(x+a\geqslant b+y)=\mathbb P(x+a\gt b+y)$, that is, where $\mathbb P(x+a=b+y)=0$.
