Gibbs' inequality

In information theory, Gibbs' inequality is a statement about the information entropy of a discrete probability distribution. Several other bounds on the entropy of probability distributions are derived from Gibbs' inequality, including Fano's inequality. It was first presented by J. Willard Gibbs in the 19th century.

Gibbs' inequality
Suppose that $$ P = \{ p_1, \ldots , p_n \} $$ and $$ Q = \{ q_1 , \ldots , q_n \} $$ are discrete probability distributions. Then


 * $$ - \sum_{i=1}^n p_i \log p_i \leq - \sum_{i=1}^n p_i \log q_i $$

with equality if and only if $$ p_i = q_i $$ for $$i = 1, \dots n$$. Put in words, the information entropy of a distribution $$P$$ is less than or equal to its cross entropy with any other distribution $$Q$$.

The difference between the two quantities is the Kullback–Leibler divergence or relative entropy, so the inequality can also be written:


 * $$ D_{\mathrm{KL}}(P\|Q) \equiv \sum_{i=1}^n p_i \log \frac{p_i}{q_i} \geq 0.$$

Note that the use of base-2 logarithms is optional, and allows one to refer to the quantity on each side of the inequality as an "average surprisal" measured in bits.

Proof
For simplicity, we prove the statement using the natural logarithm, denoted by $ln$, since


 * $$ \log_b a = \frac{ \ln a }{ \ln b },$$

so the particular logarithm base $b > 1$ that we choose only scales the relationship by the factor $1 / ln b$.

Let $$I$$ denote the set of all $$i$$ for which pi is non-zero. Then, since $$ \ln x \leq x-1 $$ for all x > 0, with equality if and only if x=1, we have:


 * $$- \sum_{i \in I} p_i \ln \frac{q_i}{p_i} \geq - \sum_{i \in I} p_i \left( \frac{q_i}{p_i} - 1 \right) $$$$ = - \sum_{i \in I} q_i + \sum_{i \in I} p_i = - \sum_{i \in I} q_i + 1 \geq 0$$

The last inequality is a consequence of the pi and qi being part of a probability distribution. Specifically, the sum of all non-zero values is 1. Some non-zero qi, however, may have been excluded since the choice of indices is conditioned upon the pi being non-zero. Therefore, the sum of the qi may be less than 1.

So far, over the index set $$I$$, we have:


 * $$ - \sum_{i \in I} p_i \ln \frac{q_i}{p_i} \geq 0 $$,

or equivalently
 * $$ - \sum_{i \in I} p_i \ln q_i \geq - \sum_{i \in I} p_i \ln p_i $$.

Both sums can be extended to all $$i=1, \ldots, n$$, i.e. including $$p_i=0$$, by recalling that the expression $$p \ln p$$ tends to 0 as $$p$$ tends to 0, and $$(-\ln q)$$ tends to $$\infty$$ as $$q$$ tends to 0. We arrive at


 * $$ - \sum_{i=1}^n p_i \ln q_i \geq - \sum_{i=1}^n p_i \ln p_i $$

For equality to hold, we require
 * 1) $$ \frac{q_i}{p_i} = 1$$ for all $$i \in I $$ so that the equality $$\ln \frac{q_i}{p_i} = \frac{q_i}{p_i} -1 $$ holds,
 * 2) and $$ \sum_{i \in I} q_i = 1$$ which means $$q_i=0$$ if $$i\notin I$$, that is, $$q_i=0$$ if $$p_i=0$$.

This can happen if and only if $$p_i = q_i $$ for $$i = 1, \ldots, n$$.

Alternative proofs
The result can alternatively be proved using Jensen's inequality, the log sum inequality, or the fact that the Kullback-Leibler divergence is a form of Bregman divergence.

Proof by Jensen's inequality
Because log is a concave function, we have that:


 * $$\sum_i p_i \log\frac{q_i}{p_i} \le \log\sum_i p_i\frac{q_i}{p_i} = \log\sum_i q_i \le 0$$

Where the first inequality is due to Jensen's inequality, and the last equality is due to the same reason given in the above proof.

Furthermore, since $$\log$$ is strictly concave, by the equality condition of Jensen's inequality we get equality when


 * $$\frac{q_1}{p_1} = \frac{q_2}{p_2} = \cdots = \frac{q_n}{p_n}$$

and


 * $$\sum_i q_i = 1$$

Suppose that this ratio is $$\sigma$$, then we have that


 * $$1 = \sum_i q_i = \sum_i \sigma p_i = \sigma$$

Where we use the fact that $$p, q$$ are probability distributions. Therefore, the equality happens when $$p = q$$.

Proof by Bregman divergence
Alternatively, it can be proved by noting that$$q - p - p\ln\frac qp \geq 0 $$for all $$p, q > 0$$, with equality holding iff $$p=q$$. Then, sum over the states, we have$$\sum_i q_i - p_i - p_i\ln\frac{q_i}{p_i} \geq 0 $$with equality holding iff $$p = q $$.

This is because the KL divergence is the Bregman divergence generated by the function $$t \mapsto \ln t$$.

Corollary
The entropy of $$P$$ is bounded by:


 * $$H(p_1, \ldots, p_n) \leq \log n. $$

The proof is trivial – simply set $$q_i = 1/n $$ for all i.