Proof of Jensen's inequality for convexity I am studying the Jensen inequality for convexity:

Let $X$ be a random variable. If $g$ is a convex function, then $E(g(X)) \ge g(E(X))$. If $g$ is a concave function, then $E(g(X)) \le g(E(X))$. In both cases, the only way that equality can hold is if there are constants $a$ and $b$ such that $g(X) = a + bX$ with probability $1$.

Then I am given a proof for this:

If $g$ is convex, then all lines that are tangent to $g$ lie below $g$ (see Figure 10.1). In particular, let $\mu = E(X)$, and consider the tangent line at the point $(\mu, g(\mu))$. (If $g$ is differentiable at $\mu$ then the tangent line is unique; otherwise, choose any tangent line at $\mu$.) Denoting this tangent line by $a + bx$, we have $g(x) \ge a + bx$ for all $x$ by convexity, so $g(X) \ge a + bX$. Taking the expectation of both sides,
$$E(g(X)) \ge E(a + bX) = a + bE(X) = a + b \mu = g(\mu) = g(E(X)),$$
as desired. If $g$ is concave, then $h = -g$ is convex, so we can apply what we just proved to $h$ to see that the inequality for $g$ is reversed from the convex case.
Lastly, assume that equality holds in the convex case. Let $Y = g(X) - a - bX$. Then $Y$ is a nonnegative r.v. with $E(Y) = 0$, so $P(Y = 0) = 1$ (even a tiny nonzero chance of $Y > 0$ occurring would make $E(Y) > 0$). So equality holds if and only if $P(g(X) = a + bX) = 1$. For the concave case, we can use the same argument with $Y = a + bX - g(X)$. $\blacksquare$


The last part of this proof is where I got confused:

Lastly, assume that equality holds in the convex case. Let $Y = g(X) - a - bX$. Then $Y$ is a nonnegative r.v. with $E(Y) = 0$, so $P(Y = 0) = 1$ (even a tiny nonzero chance of $Y > 0$ occurring would make $E(Y) > 0$). So equality holds if and only if $P(g(X) = a + bX) = 1$. For the concave case, we can use the same argument with $Y = a + bX - g(X)$.

It is my understanding that this last part of the proof is to show that the equality $E(g(X)) = g(E(X))$ only holds if there are constants $a$ and $b$ such that $g(X) = a + bX$ with probability $1$, which is why it begins with the assumption that equality holds in the convex case. However, there are a couple of points that I am confused about:

*

*Why it is valid to assume that $Y$ is a nonnegative r.v. (although, it is clear to me why $E(Y) = 0$, based on the parts of the proof that came before this part).


*Why is it that $E(Y) = 0$ implies that $P(Y = 0) = 1$?


*Why is it that even a tiny nonzero chance of $Y > 0$ occurring would make $E(Y) > 0$?
Thank you.
 A: *

*Since by convexity $g(X) \ge a + bX$, so $Y=g(X)-a-bX\geq 0$. 


2,3. The expectation property: if $Y\geq 0$ with probability $1$ and $\mathbb E(Y)=0$, then $\mathbb P(Y=0)=1$. 
Proof. Consider for every $x>0$ the event $\{Y > x\}$ and find its probability. 
$$
x\cdot\mathbb P(Y > x) \leq E (Y \mathbb 1_{Y>x}) \leq E(Y) = 0,
$$
so $\mathbb P(Y>x)=0$ for all $x>0$. Next, $Y>0$ implies that there exists $n=1,2,3,\ldots$ such that $Y>\frac1n$. Then 
$$
\mathbb P(Y>0) \leq \mathbb P\left(\bigcup_{i=1}^\infty \left\{Y>\frac1n\right\}\right)\leq \sum_{n=1}^\infty \mathbb P\left(Y>\frac1n\right) =0
$$
Therefore 
$$
1=\mathbb P(Y\geq 0)=\mathbb P(Y=0)+\underbrace{\mathbb P(Y>0)}_0 = \mathbb P(Y=0).
$$


*Proved above. If you need bases for intuition, recall that expected value can be viewd as center of gravity of a real line with unit probability mass distributed along the line. Look at some unit mass on positive halfline. If the main part of a mass is in zero, and a tiny part is right from zero, then the center of gravity of the real line is right from zero. 

