Jensen's inequality



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 proved by Jensen in 1906, building on an earlier proof of the same inequality for doubly-differentiable functions by Otto Hölder in 1889. 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]),


 * $$t f(x_1) + (1-t) f(x_2),$$

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


 * $$f(t x_1 + (1-t) x_2).$$

Thus, Jensen's inequality is
 * $$f(t x_1 + (1-t) x_2) \leq t f(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



The difference between the two sides of the inequality, $$\operatorname{E} \left[\varphi(X)\right] - \varphi\left(\operatorname{E}[X]\right)$$, is called the Jensen gap.

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 $$\varphi$$, numbers $$x_1, x_2, \ldots, x_n$$ in its domain, and positive weights $$a_i$$, Jensen's inequality can be stated as:

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

Equality holds if and only if $$x_1=x_2=\cdots =x_n$$ or $$\varphi$$ is linear on a domain containing $$x_1,x_2,\cdots ,x_n$$.

As a particular case, if the weights $$a_i$$ are all equal, then ($$) and ($$) become

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

$$\log\!\left( \frac{\sum_{i=1}^n x_i}{n}\right) \geq \frac{\sum_{i=1}^n \log\!\left( x_i \right)}{n}$$ $$\exp\!\left(\log\!\left( \frac{\sum_{i=1}^n x_i}{n}\right)\right) \geq \exp\!\left(\frac{\sum_{i=1}^n \log\!\left( x_i \right)} {n}\right)$$ $$\frac{x_1 + x_2 + \cdots + x_n}{n} \geq \sqrt[n]{x_1 \cdot x_2 \cdots x_n}$$

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

Measure-theoretic form
Let $$(\Omega, A, \mu)$$ be a probability space. Let $$f : \Omega \to \mathbb{R}$$ be a $$\mu$$-measurable function and $$\varphi : \mathbb{R} \to \mathbb{R}$$ be convex. Then:

In real analysis, we may require an estimate on


 * $$\varphi\left(\int_a^b f(x)\, dx\right)$$

where $$a, b \in \mathbb{R}$$, and $$f\colon[a, b] \to \R$$ is a non-negative Lebesgue-integrable function. In this case, the Lebesgue measure of $$[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


 * $$\varphi\left(\frac{1}{b-a}\int_a^b f(x)\, dx\right) \le \frac{1}{b-a} \int_a^b \varphi(f(x)) \,dx. $$

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


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

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

Note that the equality holds if and only if $t$ is a linear function on some convex set $$A$$ such that $$\mathrm{P}(X \in A) = 1$$ (which follows by inspecting the measure-theoretical proof below).

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 $$\operatorname{E}[X]$$ in T, such that for any element z in the dual space of T: $$\operatorname{E}|\langle z, X \rangle|<\infty $$, and $$\langle z, \operatorname{E}[X]\rangle = \operatorname{E}[\langle z, X \rangle]$$. Then, for any measurable convex function $φ$ and any sub-σ-algebra $$\mathfrak{G}$$ of $$\mathfrak{F}$$:


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

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

A sharpened and generalized form
Let X be a one-dimensional random variable with mean $$\mu$$ and variance $$\sigma^2\ge 0$$. Let $$\varphi(x)$$ be a twice differentiable function, and define the function



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



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

In particular, when $$\varphi(x)$$ is convex, then $$\varphi''(x)\ge 0$$, and the standard form of Jensen's inequality immediately follows for the case where $$\varphi(x)$$ is additionally assumed to be twice differentiable.

Intuitive graphical proof




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 $φ$ is a real number (see figure). Assuming a hypothetical distribution of $φ$ values, one can immediately identify the position of $$\operatorname{E}[X]$$ and its image $$ \varphi(\operatorname{E}[X])$$ in the graph. Noticing that for convex mappings $Y(X)$ of some $T$ values the corresponding distribution of $σ$ values is increasingly "stretched up" for increasing values of $X$, it is easy to see that the distribution of $X$ is broader in the interval corresponding to $1$ and narrower in $Y = φ(x)$ for any $X > X_{0}$; in particular, this is also true for $$ X_0 = \operatorname{E}[X]$$. Consequently, in this picture the expectation of $Y$ will always shift upwards with respect to the position of $$ \varphi(\operatorname{E}[X])$$. A similar reasoning holds if the distribution of $Y$ covers a decreasing portion of the convex function, or both a decreasing and an increasing portion of it. This "proves" the inequality, i.e.


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

with equality when $X < X_{0}$ 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 $X_{0}$ and $φ(X)$ are two arbitrary nonnegative real numbers such that $λ_{1}$ then convexity of $n$ implies


 * $$\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 generalized: if $λ_{2}$ are nonnegative real numbers such that $λ_{1} + λ_{2} = 1$, then


 * $$\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 $λ_{1}, ..., λ_{n}$.

The finite form of the Jensen's inequality can be proved by induction: by convexity hypotheses, the statement is true for n = 2. Suppose the statement is true for some n, so


 * $$\varphi\left(\sum_{i=1}^{n}\lambda_i x_i\right) \leq \sum_{i=1}^{n}\lambda_i \varphi\left(x_i\right)

$$

for any $λ_{1} + ... + λ_{n} = 1$ such that $x_{1}, ..., x_{n}$.

One needs to prove it for $λ_{1}, ..., λ_{n}$. At least one of the $λ_{1} + ... + λ_{n} = 1$ is strictly smaller than $$1$$, say $n + 1$; therefore by convexity inequality:


 * $$\begin{align}

\varphi\left(\sum_{i=1}^{n+1}\lambda_i x_i\right) &= \varphi\left((1-\lambda_{n+1})\sum_{i=1}^{n} \frac{\lambda_i}{1-\lambda_{n+1}} x_i + \lambda_{n+1} x_{n+1} \right) \\ &\leq (1-\lambda_{n+1}) \varphi\left(\sum_{i=1}^{n} \frac{\lambda_i}{1-\lambda_{n+1}} x_i \right)+\lambda_{n+1}\,\varphi(x_{n+1}). \end{align}$$

Since $λ_{i}$,


 * $$\sum_{i=1}^{n} \frac{\lambda_i}{1-\lambda_{n+1}} = 1$$,

applying the inductive hypothesis gives


 * $$\varphi\left(\sum_{i=1}^{n}\frac{\lambda_i}{1-\lambda_{n+1}} x_i\right) \leq \sum_{i=1}^{n}\frac{\lambda_i}{1-\lambda_{n+1}} \varphi(x_i)$$

therefore


 * $$\begin{align}

\varphi\left(\sum_{i=1}^{n+1}\lambda_i x_i\right) &\leq (1-\lambda_{n+1}) \sum_{i=1}^{n}\frac{\lambda_i}{1-\lambda_{n+1}} \varphi(x_i)+\lambda_{n+1}\,\varphi(x_{n+1}) =\sum_{i=1}^{n+1}\lambda_i \varphi(x_i) \end{align}$$

We deduce the equality is true for $λ_{n+1}$, by induction it follows that the result is also true for all integer $λ_{1} + ... +λ_{n} + λ_{n+1} = 1$ greater than 2.

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:


 * $$\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:


 * $$\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 $$\mu$$-integrable function on a probability space $$\Omega$$, and let $$\varphi$$ be a convex function on the real numbers. Since $$\varphi$$ 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 $$\varphi$$ at $$x$$, but which are below the graph of $$\varphi$$ at all points (support lines of the graph).

Now, if we define
 * $$x_0:=\int_\Omega g\, d\mu,$$

because of the existence of subderivatives for convex functions, we may choose $$a$$ and $$b$$ such that
 * $$ax + b \leq \varphi(x),$$

for all real $$x$$ and
 * $$ax_0+ b = \varphi(x_0).$$

But then we have that
 * $$\varphi \circ g (\omega) \geq ag(\omega)+ b$$

for almost all $$\omega \in \Omega$$. Since we have a probability measure, the integral is monotone with $$\mu(\Omega) = 1$$ so that


 * $$\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 $$\varphi: T \to \R$$ is convex, for any $$x,y \in T$$, the quantity


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

is decreasing as $X$ approaches 0+. In particular, the subdifferential of $$\varphi$$ evaluated at $X$ in the direction $x$ is well-defined by


 * $$(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$ (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 $n + 1$, one gets


 * $$\varphi(x)\leq \varphi(x+y)-(D\varphi)(x)\cdot y.$$

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


 * $$\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 $$ \mathfrak{G}$$ on both sides of the previous expression, we get the result since:


 * $$\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:


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

Form involving a probability density function
Suppose $n$ is a measurable subset of the real line and f(x) is a non-negative function such that


 * $$\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 $\varphi$ is convex over the range of g, then


 * $$ \varphi\left(\int_{-\infty}^\infty g(x)f(x)\, dx\right) \le \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:


 * $$\varphi\left(\int_{-\infty}^\infty x\, f(x)\, dx\right) \le \int_{-\infty}^\infty \varphi(x)\,f(x)\, dx.$$

This is applied in Variational Bayesian methods.

Example: even moments of a random variable
If g(x) = x2n, and X is a random variable, then g is convex as
 * $$ \frac{d^{2}g}{dx^{2}}(x) = 2n(2n - 1)x^{2n - 2} \geq 0\quad \forall\ x \in \R$$

and so

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 $$l\in\N$$ dividing n.

Alternative finite form
Let $θ = 1$ and take $Y$ to be the counting measure on $Ω$, then the general form reduces to a statement about sums:


 * $$ \varphi\left(\sum_{i=1}^{n} g(x_i)\lambda_i \right) \le \sum_{i=1}^{n} \varphi(g(x_i)) \lambda_i, $$

provided that $Ω = {x_{1}, ... x_{n}},$ and


 * $$\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:


 * $$ 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 $Y$.

Proof: Let $$\varphi(x) = e^x$$ in $$\varphi\left(\operatorname{E}[X]\right) \leq \operatorname{E} \left[ \varphi(X) \right].$$

Information theory
If $Ω$ is the true probability density for $X$, and $λ_{i} ≥ 0$ is another density, then applying Jensen's inequality for the random variable $p(x)$ and the convex function $q(x)$ gives


 * $$\operatorname{E}[\varphi(Y)] \ge \varphi(\operatorname{E}[Y])$$

Therefore:


 * $$-D(p(x)\|q(x))=\int p(x) \log \left (\frac{q(x)}{p(x)} \right ) \, dx \le \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, where $$D(p(x)\|q(x))=\int p(x) \log \left (\frac{p(x)}{q(x)} \right ) dx$$.

Since $Y(X) = q(X)/p(X)$ is a strictly convex function for $φ(y) = −log(y)$, it follows that equality holds when $−log(x)$ equals $x > 0$ almost everywhere.

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


 * $$L(\operatorname{E}[\delta(X) \mid \mathfrak{G}]) \le \operatorname{E}[L(\delta(X)) \mid \mathfrak{G}] \quad \Longrightarrow \quad \operatorname{E}[L(\operatorname{E}[\delta(X) \mid \mathfrak{G}])] \le \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


 * $$\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. Further, because T is a sufficient statistics, $$\delta_1 (X)$$ does not depend on θ, hence, becomes a statistics.

This result is known as the Rao–Blackwell theorem.