# Jensen's inequality

Jensen's inequality generalizes the statement that a secant line of a convex function lies above the graph.

In mathematics, Jensen's inequality, named after the Danish mathematician Johan Jensen, relates the value of a convex function of an integral to the integral of the convex function. It was proven by Jensen in 1906.[1] Given its generality, the inequality appears in many forms depending on the context, some of which are presented below. In its simplest form the inequality states that the convex transformation of a mean is less than or equal to the mean applied after convex transformation; it is a simple corollary that the opposite is true of concave transformations.

Jensen's inequality generalizes the statement that the secant line of a convex function lies above the graph of the function, which is Jensen's inequality for two points: the secant line consists of weighted means of the convex function (for t ∈ [0,1]),

${\displaystyle tf(x_{1})+(1-t)f(x_{2}),}$

while the graph of the function is the convex function of the weighted means,

${\displaystyle f\left(tx_{1}+(1-t)x_{2}\right).}$

Thus, Jensen's inequality is

${\displaystyle f\left(tx_{1}+(1-t)x_{2}\right)\leq tf(x_{1})+(1-t)f(x_{2}).}$

In the context of probability theory, it is generally stated in the following form: if X is a random variable and φ is a convex function, then

${\displaystyle \varphi \left(\operatorname {E} [X]\right)\leq \operatorname {E} \left[\varphi (X)\right].}$

## Statements

The classical form of Jensen's inequality involves several numbers and weights. The inequality can be stated quite generally using either the language of measure theory or (equivalently) probability. In the probabilistic setting, the inequality can be further generalized to its full strength.

### Finite form

For a real convex function ${\displaystyle \varphi }$, numbers ${\displaystyle x_{1},x_{2},\ldots ,x_{n}}$ in its domain, and positive weights ${\displaystyle a_{i}}$, Jensen's inequality can be stated as:

${\displaystyle \varphi \left({\frac {\sum a_{i}x_{i}}{\sum a_{i}}}\right)\leq {\frac {\sum a_{i}\varphi (x_{i})}{\sum a_{i}}}\qquad \qquad (1)}$

and the inequality is reversed if ${\displaystyle \varphi }$ is concave, which is

${\displaystyle \varphi \left({\frac {\sum a_{i}x_{i}}{\sum a_{i}}}\right)\geq {\frac {\sum a_{i}\varphi (x_{i})}{\sum a_{i}}}.\qquad \qquad (2)}$

Equality holds if and only if ${\displaystyle x_{1}=x_{2}=\cdots =x_{n}}$ or ${\displaystyle \varphi }$ is linear.

As a particular case, if the weights ${\displaystyle a_{i}}$ are all equal, then (1) and (2) become

${\displaystyle \varphi \left({\frac {\sum x_{i}}{n}}\right)\leq {\frac {\sum \varphi (x_{i})}{n}}\qquad \qquad (3)}$
${\displaystyle \varphi \left({\frac {\sum x_{i}}{n}}\right)\geq {\frac {\sum \varphi (x_{i})}{n}}\qquad \qquad (4)}$

For instance, the function log(x) is concave, so substituting ${\displaystyle \varphi (x)=\log(x)}$ in the previous formula (4) establishes the (logarithm of the) familiar arithmetic mean-geometric mean inequality:

${\displaystyle \log \!\left({\frac {\sum _{i=1}^{n}x_{i}}{n}}\right)\geq {\frac {\sum _{i=1}^{n}\log \!\left(x_{i}\right)}{n}}\quad {\text{or}}\quad {\frac {x_{1}+x_{2}+\cdots +x_{n}}{n}}\geq {\sqrt[{n}]{x_{1}\cdot x_{2}\cdots x_{n}}}}$

A common application has ${\displaystyle x}$ as a function of another variable (or set of variables) ${\displaystyle t}$, that is, ${\displaystyle x_{i}=g(t_{i})}$. All of this carries directly over to the general continuous case: the weights ai are replaced by a non-negative integrable function f (x), such as a probability distribution, and the summations are replaced by integrals.

### Measure-theoretic and probabilistic form

Let ${\displaystyle (\Omega ,A,\mu )}$ be a probability space, such that ${\displaystyle \mu (\Omega )=1}$. If ${\displaystyle g}$ is a real-valued function that is ${\displaystyle \mu }$-integrable, and if ${\displaystyle \varphi }$ is a convex function on the real line, then:

${\displaystyle \varphi \left(\int _{\Omega }g\,d\mu \right)\leq \int _{\Omega }\varphi \circ g\,d\mu .}$

In real analysis, we may require an estimate on

${\displaystyle \varphi \left(\int _{a}^{b}f(x)\,dx\right),}$

where ${\displaystyle a,b\in \mathbb {R} }$, and ${\displaystyle f:[a,b]\to \mathbb {R} }$ is a non-negative Lebesgue-integrable function. In this case, the Lebesgue measure of ${\displaystyle [a,b]}$ need not be unity. However, by integration by substitution, the interval can be rescaled so that it has measure unity. Then Jensen's inequality can be applied to get[2]

${\displaystyle \varphi \left({\frac {1}{b-a}}\int _{a}^{b}f(x)\,dx\right)\leq {\frac {1}{b-a}}\int _{a}^{b}\varphi (f(x))\,dx.}$

The same result can be equivalently stated in a probability theory setting, by a simple change of notation. Let ${\displaystyle (\Omega ,{\mathfrak {F}},\operatorname {P} )}$ be a probability space, X an integrable real-valued random variable and φ a convex function. Then:

${\displaystyle \varphi \left(\operatorname {E} [X]\right)\leq \operatorname {E} \left[\varphi (X)\right].}$

In this probability setting, the measure μ is intended as a probability ${\displaystyle \operatorname {P} }$, the integral with respect to μ as an expected value ${\displaystyle \operatorname {E} }$, and the function ${\displaystyle g}$ as a random variable X.

Notice that the equality holds if X is constant (degenerate random variable) or if φ is linear, and even if there is ${\displaystyle A\subset \mathbb {R} }$ (a Borel set, in fact) such that

${\displaystyle \Pr(X\in A)=1}$

and φ is a linear function over A (that is, there are ${\displaystyle a,b\in \mathbb {R} }$ such that ${\displaystyle \varphi (x)=ax+b,\forall x\in A}$).

### General inequality in a probabilistic setting

More generally, let T be a real topological vector space, and X a T-valued integrable random variable. In this general setting, integrable means that there exists an element ${\displaystyle \operatorname {E} [X]}$ in T, such that for any element z in the dual space of T: ${\displaystyle \operatorname {E} |\langle z,X\rangle |<\infty }$, and ${\displaystyle \langle z,\operatorname {E} [X]\rangle =\operatorname {E} [\langle z,X\rangle ]}$. Then, for any measurable convex function φ and any sub-σ-algebra ${\displaystyle {\mathfrak {G}}}$ of ${\displaystyle {\mathfrak {F}}}$:

${\displaystyle \varphi \left(\operatorname {E} \left[X\mid {\mathfrak {G}}\right]\right)\leq \operatorname {E} \left[\varphi (X)\mid {\mathfrak {G}}\right].}$

Here ${\displaystyle \operatorname {E} [\cdot \mid {\mathfrak {G}}]}$ stands for the expectation conditioned to the σ-algebra ${\displaystyle {\mathfrak {G}}}$. This general statement reduces to the previous ones when the topological vector space T is the real axis, and ${\displaystyle {\mathfrak {G}}}$ is the trivial σ-algebra {∅, Ω}.[3]

### A sharpened and generalized form

Let X be a one-dimensional random variable with mean ${\displaystyle \mu }$ and variance ${\displaystyle \sigma ^{2}\geq 0}$. Let ${\displaystyle \varphi (x)}$ be a twice differentiable function, and define the function

${\displaystyle h(x)\triangleq {\frac {\varphi \left(x\right)-\varphi \left(\mu \right)}{\left(x-\mu \right)^{2}}}-{\frac {\varphi '\left(\mu \right)}{x-\mu }}.}$

Then[4]

${\displaystyle \sigma ^{2}\inf {\frac {\varphi ''(x)}{2}}\leq \sigma ^{2}\inf h(x)\leq E\left[\varphi \left(X\right)\right]-\varphi \left(E[X]\right)\leq \sigma ^{2}\sup h(x)\leq \sigma ^{2}\sup {\frac {\varphi ''(x)}{2}}.}$

In particular, when ${\displaystyle \varphi (x)}$ is convex, then ${\displaystyle \varphi ''(x)\geq 0}$, and the standard form of Jensen's inequality immediately follows.

## Proofs

A graphical "proof" of Jensen's inequality for the probabilistic case. The dashed curve along the X axis is the hypothetical distribution of X, while the dashed curve along the Y axis is the corresponding distribution of Y values. Note that the convex mapping Y(X) increasingly "stretches" the distribution for increasing values of X.

Jensen's inequality can be proved in several ways, and three different proofs corresponding to the different statements above will be offered. Before embarking on these mathematical derivations, however, it is worth analyzing an intuitive graphical argument based on the probabilistic case where X is a real number (see figure). Assuming a hypothetical distribution of X values, one can immediately identify the position of ${\displaystyle \operatorname {E} [X]}$ and its image ${\displaystyle \varphi (\operatorname {E} [X])}$ in the graph. Noticing that for convex mappings Y = φ(X) the corresponding distribution of Y values is increasingly "stretched out" for increasing values of X, it is easy to see that the distribution of Y is broader in the interval corresponding to X > X0 and narrower in X < X0 for any X0; in particular, this is also true for ${\displaystyle X_{0}=\operatorname {E} [X]}$. Consequently, in this picture the expectation of Y will always shift upwards with respect to the position of ${\displaystyle \varphi (\operatorname {E} [X])}$. A similar reasoning holds if the distribution of X covers a decreasing portion of the convex function, or both a decreasing and an increasing portion of it. This "proves" the inequality, i.e.

${\displaystyle \varphi (\operatorname {E} [X])\leq \operatorname {E} [\varphi (X)]=\operatorname {E} [Y],}$

with equality when φ(X) is not strictly convex, e.g. when it is a straight line, or when X follows a degenerate distribution (i.e. is a constant).

The proofs below formalize this intuitive notion.

### Proof 1 (finite form)

If λ1 and λ2 are two arbitrary nonnegative real numbers such that λ1 + λ2 = 1 then convexity of φ implies

${\displaystyle \forall x_{1},x_{2}:\qquad \varphi \left(\lambda _{1}x_{1}+\lambda _{2}x_{2}\right)\leq \lambda _{1}\,\varphi (x_{1})+\lambda _{2}\,\varphi (x_{2}).}$

This can be easily generalized: if λ1, ..., λn are nonnegative real numbers such that λ1 + ... + λn = 1, then

${\displaystyle \varphi (\lambda _{1}x_{1}+\lambda _{2}x_{2}+\cdots +\lambda _{n}x_{n})\leq \lambda _{1}\,\varphi (x_{1})+\lambda _{2}\,\varphi (x_{2})+\cdots +\lambda _{n}\,\varphi (x_{n}),}$

for any x1, ..., xn. This finite form of the Jensen's inequality can be proved by induction: by convexity hypotheses, the statement is true for n = 2. Suppose it is true also for some n, one needs to prove it for n + 1. At least one of the λi is strictly positive, say λ1; therefore by convexity inequality:

{\displaystyle {\begin{aligned}\varphi \left(\sum _{i=1}^{n+1}\lambda _{i}x_{i}\right)&=\varphi \left(\lambda _{1}x_{1}+(1-\lambda _{1})\sum _{i=2}^{n+1}{\frac {\lambda _{i}}{1-\lambda _{1}}}x_{i}\right)\\&\leq \lambda _{1}\,\varphi (x_{1})+(1-\lambda _{1})\varphi \left(\sum _{i=2}^{n+1}{\frac {\lambda _{i}}{1-\lambda _{1}}}x_{i}\right).\end{aligned}}}

Since

${\displaystyle \sum _{i=2}^{n+1}{\frac {\lambda _{i}}{1-\lambda _{1}}}=1,}$

one can apply the induction hypotheses to the last term in the previous formula to obtain the result, namely the finite form of the Jensen's inequality.

In order to obtain the general inequality from this finite form, one needs to use a density argument. The finite form can be rewritten as:

${\displaystyle \varphi \left(\int x\,d\mu _{n}(x)\right)\leq \int \varphi (x)\,d\mu _{n}(x),}$

where μn is a measure given by an arbitrary convex combination of Dirac deltas:

${\displaystyle \mu _{n}=\sum _{i=1}^{n}\lambda _{i}\delta _{x_{i}}.}$

Since convex functions are continuous, and since convex combinations of Dirac deltas are weakly dense in the set of probability measures (as could be easily verified), the general statement is obtained simply by a limiting procedure.

### Proof 2 (measure-theoretic form)

Let g be a real-valued μ-integrable function on a probability space Ω, and let φ be a convex function on the real numbers. Since φ is convex, at each real number x we have a nonempty set of subderivatives, which may be thought of as lines touching the graph of φ at x, but which are at or below the graph of φ at all points (support lines of the graph).

Now, if we define

${\displaystyle x_{0}:=\int _{\Omega }g\,d\mu ,}$

because of the existence of subderivatives for convex functions, we may choose a and b such that

${\displaystyle ax+b\leq \varphi (x),}$

for all real x and

${\displaystyle ax_{0}+b=\varphi (x_{0}).}$

But then we have that

${\displaystyle \varphi \circ g(x)\geq ag(x)+b}$

for all x. Since we have a probability measure, the integral is monotone with μ(Ω) = 1 so that

${\displaystyle \int _{\Omega }\varphi \circ g\,d\mu \geq \int _{\Omega }(ag+b)\,d\mu =a\int _{\Omega }g\,d\mu +b\int _{\Omega }d\mu =ax_{0}+b=\varphi (x_{0})=\varphi \left(\int _{\Omega }g\,d\mu \right),}$

as desired.

### Proof 3 (general inequality in a probabilistic setting)

Let X be an integrable random variable that takes values in a real topological vector space T. Since ${\displaystyle \varphi :T\to \mathbb {R} }$ is convex, for any ${\displaystyle x,y\in T}$, the quantity

${\displaystyle {\frac {\varphi (x+\theta \,y)-\varphi (x)}{\theta }},}$

is decreasing as θ approaches 0+. In particular, the subdifferential of φ evaluated at x in the direction y is well-defined by

${\displaystyle (D\varphi )(x)\cdot y:=\lim _{\theta \downarrow 0}{\frac {\varphi (x+\theta \,y)-\varphi (x)}{\theta }}=\inf _{\theta \neq 0}{\frac {\varphi (x+\theta \,y)-\varphi (x)}{\theta }}.}$

It is easily seen that the subdifferential is linear in y[citation needed] (that is false and the assertion requires Hahn-Banach theorem to be proved) and, since the infimum taken in the right-hand side of the previous formula is smaller than the value of the same term for θ = 1, one gets

${\displaystyle \varphi (x)\leq \varphi (x+y)-(D\varphi )(x)\cdot y.}$

In particular, for an arbitrary sub-σ-algebra ${\displaystyle {\mathfrak {G}}}$ we can evaluate the last inequality when ${\displaystyle x=\operatorname {E} [X\mid {\mathfrak {G}}],\,y=X-\operatorname {E} [X\mid {\mathfrak {G}}]}$ to obtain

${\displaystyle \varphi (\operatorname {E} [X\mid {\mathfrak {G}}])\leq \varphi (X)-(D\varphi )(\operatorname {E} [X\mid {\mathfrak {G}}])\cdot (X-\operatorname {E} [X\mid {\mathfrak {G}}]).}$

Now, if we take the expectation conditioned to ${\displaystyle {\mathfrak {G}}}$ on both sides of the previous expression, we get the result since:

${\displaystyle \operatorname {E} \left[\left[(D\varphi )(\operatorname {E} [X\mid {\mathfrak {G}}])\cdot (X-\operatorname {E} [X\mid {\mathfrak {G}}])\right]\mid {\mathfrak {G}}\right]=(D\varphi )(\operatorname {E} [X\mid {\mathfrak {G}}])\cdot \operatorname {E} [\left(X-\operatorname {E} [X\mid {\mathfrak {G}}]\right)\mid {\mathfrak {G}}]=0,}$

by the linearity of the subdifferential in the y variable, and the following well-known property of the conditional expectation:

${\displaystyle \operatorname {E} \left[\left(\operatorname {E} [X\mid {\mathfrak {G}}]\right)\mid {\mathfrak {G}}\right]=\operatorname {E} [X\mid {\mathfrak {G}}].}$

## Applications and special cases

### Form involving a probability density function

Suppose Ω is a measurable subset of the real line and f(x) is a non-negative function such that

${\displaystyle \int _{-\infty }^{\infty }f(x)\,dx=1.}$

In probabilistic language, f is a probability density function.

Then Jensen's inequality becomes the following statement about convex integrals:

If g is any real-valued measurable function and ${\textstyle \varphi }$ is convex over the range of g, then

${\displaystyle \varphi \left(\int _{-\infty }^{\infty }g(x)f(x)\,dx\right)\leq \int _{-\infty }^{\infty }\varphi (g(x))f(x)\,dx.}$

If g(x) = x, then this form of the inequality reduces to a commonly used special case:

${\displaystyle \varphi \left(\int _{-\infty }^{\infty }x\,f(x)\,dx\right)\leq \int _{-\infty }^{\infty }\varphi (x)\,f(x)\,dx.}$

### Example: even moments of a random variable

If g(x) = x2n, and X is a random variable, then g is convex as

${\displaystyle {\frac {d^{2}g}{dx^{2}}}(x)=2n(2n-1)x^{2n-2}\geq 0\quad \forall \ x\in \mathbb {R} }$

and so

${\displaystyle g(\operatorname {E} [X])=(\operatorname {E} [X])^{2n}\leq \operatorname {E} [X^{2n}].}$

In particular, if some even moment 2n of X is finite, X has a finite mean. An extension of this argument shows X has finite moments of every order ${\displaystyle l\in \mathbb {N} }$ dividing n.

### Alternative finite form

Let Ω = {x1, ... xn}, and take μ to be the counting measure on Ω, then the general form reduces to a statement about sums:

${\displaystyle \varphi \left(\sum _{i=1}^{n}g(x_{i})\lambda _{i}\right)\leq \sum _{i=1}^{n}\varphi (g(x_{i}))\lambda _{i},}$

provided that λi ≥ 0 and

${\displaystyle \lambda _{1}+\cdots +\lambda _{n}=1.}$

There is also an infinite discrete form.

### Statistical physics

Jensen's inequality is of particular importance in statistical physics when the convex function is an exponential, giving:

${\displaystyle e^{\operatorname {E} [X]}\leq \operatorname {E} \left[e^{X}\right],}$

where the expected values are with respect to some probability distribution in the random variable X.

The proof in this case is very simple (cf. Chandler, Sec. 5.5). The desired inequality follows directly, by writing

${\displaystyle \operatorname {E} \left[e^{X}\right]=e^{\operatorname {E} [X]}\operatorname {E} \left[e^{X-\operatorname {E} [X]}\right]}$

and then applying the inequality eX ≥ 1 + X to the final exponential.

### Information theory

If p(x) is the true probability density for X, and q(x) is another density, then applying Jensen's inequality for the random variable Y(X) = q(X)/p(X) and the convex function φ(y) = −log(y) gives

${\displaystyle \operatorname {E} [\varphi (Y)]\geq \varphi (\operatorname {E} [Y])}$

Therefore:

${\displaystyle -D(p(x)\|q(x))=\int p(x)\log \left({\frac {q(x)}{p(x)}}\right)\,dx\leq \log \left(\int p(x){\frac {q(x)}{p(x)}}\,dx\right)=\log \left(\int q(x)\,dx\right)=0}$

a result called Gibbs' inequality.

It shows that the average message length is minimised when codes are assigned on the basis of the true probabilities p rather than any other distribution q. The quantity that is non-negative is called the Kullback–Leibler divergence of q from p.

Since −log(x) is a strictly convex function for x > 0, it follows that equality holds when p(x) equals q(x) almost everywhere.

### Rao–Blackwell theorem

If L is a convex function and ${\displaystyle {\mathfrak {G}}}$ a sub-sigma-algebra, then, from the conditional version of Jensen's inequality, we get

${\displaystyle L(\operatorname {E} [\delta (X)\mid {\mathfrak {G}}])\leq \operatorname {E} [L(\delta (X))\mid {\mathfrak {G}}]\quad \Longrightarrow \quad \operatorname {E} [L(\operatorname {E} [\delta (X)\mid {\mathfrak {G}}])]\leq \operatorname {E} [L(\delta (X))].}$

So if δ(X) is some estimator of an unobserved parameter θ given a vector of observables X; and if T(X) is a sufficient statistic for θ; then an improved estimator, in the sense of having a smaller expected loss L, can be obtained by calculating

${\displaystyle \delta _{1}(X)=\operatorname {E} _{\theta }[\delta (X')\mid T(X')=T(X)],}$

the expected value of δ with respect to θ, taken over all possible vectors of observations X compatible with the same value of T(X) as that observed.

This result is known as the Rao–Blackwell theorem.