Expectation of positive part of a random variable Given a random variable $X$, does the following inequality hold?
\begin{equation*}
\mathbb{E}[\max\{X,0\}]=\max\{\mathbb{E}[X],0\}
\end{equation*}
I know that in general for a function $f(X)$ the equality does not hold. I just wondered whether it is the same for the positive part function.
 A: Example where the equality does hold:  $$\Pr[X \ge 0] = 1,$$ namely any random variable with nonnegative support.  Examples include the exponential distribution $$f_X(x) = \lambda e^{-\lambda x} \mathbb 1 (x \ge 0), \quad \lambda > 0.$$
Example where the equality does not hold:  $$X = 2Y - 1, \quad Y \sim \operatorname{Bernoulli}(1/2).$$  Then $$\max\{X,0\} = \begin{cases} 0, & X = -1 \\ 1, & X = 1 \end{cases}$$ and $$\operatorname{E}[\max\{X,0\}] = 0 \cdot \frac{1}{2} + 1 \cdot \frac{1}{2} = \frac{1}{2},$$ but $$\max\{\operatorname{E}[X],0\} = \max\{2\operatorname{E}[Y]-1, 0\} = \max\{2 \cdot\tfrac{1}{2} - 1, 0\} = 0.$$
A: Since $$f\colon x\mapsto \max(x,0)$$ is a convex function, you have one inequality by Jensen:
$$
 \max(\mathbb{E}[X],0) \leq \mathbb{E}[\max(X,0)] \tag{$\dagger$}
$$
The other inequality, however, is false in general. For it to hold, the equality case of Jensen's inequality says that you need $X$ to be a constant a.s., or to have support in a set where $f$ is linear. I.e., given our specific $f$, overall, you need $X\leq 0$ a.s. or $X\geq 0$ a.s. for $(\dagger)$ to be an equality.
A: RHS $\leq $ LHS and equality holds iff $X \geq 0$ almost surely or $X \leq 0$ almost surely.
For a proof just use the fact that $Y 
\geq 0$ almost surely and $EY=0$ implies $Y=0$ almost surely. [Take $Y=\max \{X ,0\}-X$ when $EX \geq 0$ and $Y=\max \{X ,0\}$ when $EX <0$]. 
