Why averages can mislead
A convex penalty makes large deviations count disproportionately: applying the penalty after averaging is smaller than averaging the penalties. For concave functions the inequality reverses. This is useful in probability, statistics, and machine learning, but first check that the function is convex on the relevant domain and that the expectations exist.
For example, because log(x) is concave on x > 0, E[log X] ≤ log(E[X]). It is not valid to switch these expressions freely. See expectation and variance and convexity.
Check the function, domain, and equality case
A function is convex if its graph bends upward, or equivalently if every chord lies on or above the graph. For a differentiable function, its tangent line lies below the graph. Jensen applies this shape property to a weighted average: if X takes x₁,…,xₙ with probabilities pᵢ, then f(Σpᵢxᵢ)≤Σpᵢf(xᵢ). The probabilities must be nonnegative and sum to one, and the relevant expectations must exist.
For values 1 and 3 with equal probability and f(x)=x², f(E[X])=f(2)=4, while E[f(X)]=(1+9)/2=5. The gap is the variance, 1. If f is concave, such as log(x) on positive inputs, the inequality reverses. Equality occurs when the function is affine over the values with positive probability; it need not require X to be constant. Jensen is useful for bounding expectations, but it does not allow you to move a nonlinear function through an average without checking convexity and domain.
Try this above
Compare f at the mean with the mean of f-values as the spread changes. For a convex curve, the latter should stay at least as large.
For a random variable with finitely many outcomes, the inequality is a weighted average with weights P(X=xᵢ); it is not limited to equally likely cases. For example, if X=0 with probability 0.75 and X=4 with probability 0.25, then E[X]=1. With f(x)=x², f(E[X])=1 while E[f(X)]=4. The larger outcome has a disproportionate effect after squaring. This is the same mechanism behind variance penalties and why averaging losses before applying a nonlinear transformation can change the result.
Jensen also gives a useful relationship between arithmetic and geometric means. Since log is concave, E[log X]≤log(E[X]) for positive X. Exponentiating yields the geometric mean no greater than the arithmetic mean under the corresponding equal-weight setup. This does not say one is a better summary in every setting: the geometric mean is natural for multiplicative growth rates, while the arithmetic mean is natural for additive totals. Choosing the scale and function reflects the process being described.