When Jensen's inequality is equality

One form of Jensen's inequality is

If $X$ is a random variable and $g$ is a convex function, then $\mathbb{E}(g(X))\geq g(\mathbb{E}(X))$.

Just out of curiosity, when do we have equality? If and only if $g$ is constant?


Solution 1:

Just for the sake of having an "answered" question (thanks to @hardmath and @Did), Jensen's inequality is equality when $g$ is affine and/or $X$ is constant a.s.