# Conditional entropy

Venn diagram showing additive and subtractive relationships various information measures associated with correlated variables ${\displaystyle X}$ and ${\displaystyle Y}$. The area contained by both circles is the joint entropy ${\displaystyle \mathrm {H} (X,Y)}$. The circle on the left (red and violet) is the individual entropy ${\displaystyle \mathrm {H} (X)}$, with the red being the conditional entropy ${\displaystyle \mathrm {H} (X|Y)}$. The circle on the right (blue and violet) is ${\displaystyle \mathrm {H} (Y)}$, with the blue being ${\displaystyle \mathrm {H} (Y|X)}$. The violet is the mutual information ${\displaystyle \operatorname {I} (X;Y)}$.

In information theory, the conditional entropy quantifies the amount of information needed to describe the outcome of a random variable ${\displaystyle Y}$ given that the value of another random variable ${\displaystyle X}$ is known. Here, information is measured in shannons, nats, or hartleys. The entropy of ${\displaystyle Y}$ conditioned on ${\displaystyle X}$ is written as ${\displaystyle \mathrm {H} (Y|X)}$.

## Definition

The conditional entropy of ${\displaystyle Y}$ given ${\displaystyle X}$ is defined as

${\displaystyle \mathrm {H} (Y|X)\ =-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log {\frac {p(x,y)}{p(x)}}}$

(Eq.1)

where ${\displaystyle {\mathcal {X}}}$ and ${\displaystyle {\mathcal {Y}}}$ denote the support sets of ${\displaystyle X}$ and ${\displaystyle Y}$.

Note: It is conventioned that the expressions ${\displaystyle 0\log 0}$ and ${\displaystyle 0\log c/0}$ for fixed ${\displaystyle c>0}$ should be treated as being equal to zero. This is because ${\displaystyle \lim _{\theta \to 0^{+}}\theta \,\log \,c/\theta =0}$ and ${\displaystyle \lim _{\theta \to 0^{+}}\theta \,\log \theta =0}$[1]

Intuitive explanation of the definition : According to the definition, ${\displaystyle \displaystyle H(Y|X)=\mathbb {E} (\ f(X,Y)\ )}$ where ${\displaystyle \displaystyle f:(x,y)\ \rightarrow -\log(\ p(y|x)\ ).}$ ${\displaystyle \displaystyle f}$ associates to ${\displaystyle \displaystyle (x,y)}$ the information content of ${\displaystyle \displaystyle (Y=y)}$ given ${\displaystyle \displaystyle (X=x)}$, which is the amount of information needed to describe the event ${\displaystyle \displaystyle (Y=y)}$ given ${\displaystyle (X=x)}$. According to the law of large numbers, ${\displaystyle \displaystyle H(Y|X)}$ is the arithmetic mean of a large number of independent realizations of ${\displaystyle \displaystyle f(X,Y)}$.

## Motivation

Let ${\displaystyle \mathrm {H} (Y|X=x)}$ be the entropy of the discrete random variable ${\displaystyle Y}$ conditioned on the discrete random variable ${\displaystyle X}$ taking a certain value ${\displaystyle x}$. Denote the support sets of ${\displaystyle X}$ and ${\displaystyle Y}$ by ${\displaystyle {\mathcal {X}}}$ and ${\displaystyle {\mathcal {Y}}}$. Let ${\displaystyle Y}$ have probability mass function ${\displaystyle p_{Y}{(y)}}$. The unconditional entropy of ${\displaystyle Y}$ is calculated as ${\displaystyle \mathrm {H} (Y):=\mathbb {E} [\operatorname {I} (Y)]}$, i.e.

${\displaystyle \mathrm {H} (Y)=\sum _{y\in {\mathcal {Y}}}{\mathrm {Pr} (Y=y)\,\mathrm {I} (y)}=-\sum _{y\in {\mathcal {Y}}}{p_{Y}(y)\log _{2}{p_{Y}(y)}},}$

where ${\displaystyle \operatorname {I} (y_{i})}$ is the information content of the outcome of ${\displaystyle Y}$ taking the value ${\displaystyle y_{i}}$. The entropy of ${\displaystyle Y}$ conditioned on ${\displaystyle X}$ taking the value ${\displaystyle x}$ is defined analogously by conditional expectation:

${\displaystyle \mathrm {H} (Y|X=x)=-\sum _{y\in {\mathcal {Y}}}{\Pr(Y=y|X=x)\log _{2}{\Pr(Y=y|X=x)}}.}$

Note that ${\displaystyle \mathrm {H} (Y|X)}$ is the result of averaging ${\displaystyle \mathrm {H} (Y|X=x)}$ over all possible values ${\displaystyle x}$ that ${\displaystyle X}$ may take. Also, if the above sum is taken over a sample ${\displaystyle y_{1},\dots ,y_{n}}$, the expected value ${\displaystyle E_{X}[\mathrm {H} (y_{1},\dots ,y_{n}\mid X=x)]}$ is known in some domains as equivocation.[2]

Given discrete random variables ${\displaystyle X}$ with image ${\displaystyle {\mathcal {X}}}$ and ${\displaystyle Y}$ with image ${\displaystyle {\mathcal {Y}}}$, the conditional entropy of ${\displaystyle Y}$ given ${\displaystyle X}$ is defined as the weighted sum of ${\displaystyle \mathrm {H} (Y|X=x)}$ for each possible value of ${\displaystyle x}$, using ${\displaystyle p(x)}$ as the weights:[3]: 15

{\displaystyle {\begin{aligned}\mathrm {H} (Y|X)\ &\equiv \sum _{x\in {\mathcal {X}}}\,p(x)\,\mathrm {H} (Y|X=x)\\&=-\sum _{x\in {\mathcal {X}}}p(x)\sum _{y\in {\mathcal {Y}}}\,p(y|x)\,\log \,p(y|x)\\&=-\sum _{x\in {\mathcal {X}}}\sum _{y\in {\mathcal {Y}}}\,p(x,y)\,\log \,p(y|x)\\&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log \,p(y|x)\\&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log {\frac {p(x,y)}{p(x)}}.\\&=\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log {\frac {p(x)}{p(x,y)}}.\\\end{aligned}}}

## Properties

### Conditional entropy equals zero

${\displaystyle \mathrm {H} (Y|X)=0}$ if and only if the value of ${\displaystyle Y}$ is completely determined by the value of ${\displaystyle X}$.

### Conditional entropy of independent random variables

Conversely, ${\displaystyle \mathrm {H} (Y|X)=\mathrm {H} (Y)}$ if and only if ${\displaystyle Y}$ and ${\displaystyle X}$ are independent random variables.

### Chain rule

Assume that the combined system determined by two random variables ${\displaystyle X}$ and ${\displaystyle Y}$ has joint entropy ${\displaystyle \mathrm {H} (X,Y)}$, that is, we need ${\displaystyle \mathrm {H} (X,Y)}$ bits of information on average to describe its exact state. Now if we first learn the value of ${\displaystyle X}$, we have gained ${\displaystyle \mathrm {H} (X)}$ bits of information. Once ${\displaystyle X}$ is known, we only need ${\displaystyle \mathrm {H} (X,Y)-\mathrm {H} (X)}$ bits to describe the state of the whole system. This quantity is exactly ${\displaystyle \mathrm {H} (Y|X)}$, which gives the chain rule of conditional entropy:

${\displaystyle \mathrm {H} (Y|X)\,=\,\mathrm {H} (X,Y)-\mathrm {H} (X).}$[3]: 17

The chain rule follows from the above definition of conditional entropy:

{\displaystyle {\begin{aligned}\mathrm {H} (Y|X)&=\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log \left({\frac {p(x)}{p(x,y)}}\right)\\[4pt]&=\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)(\log(p(x))-\log(p(x,y)))\\[4pt]&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log(p(x,y))+\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}{p(x,y)\log(p(x))}\\[4pt]&=\mathrm {H} (X,Y)+\sum _{x\in {\mathcal {X}}}p(x)\log(p(x))\\[4pt]&=\mathrm {H} (X,Y)-\mathrm {H} (X).\end{aligned}}}

In general, a chain rule for multiple random variables holds:

${\displaystyle \mathrm {H} (X_{1},X_{2},\ldots ,X_{n})=\sum _{i=1}^{n}\mathrm {H} (X_{i}|X_{1},\ldots ,X_{i-1})}$[3]: 22

It has a similar form to chain rule in probability theory, except that addition instead of multiplication is used.

### Bayes' rule

Bayes' rule for conditional entropy states

${\displaystyle \mathrm {H} (Y|X)\,=\,\mathrm {H} (X|Y)-\mathrm {H} (X)+\mathrm {H} (Y).}$

Proof. ${\displaystyle \mathrm {H} (Y|X)=\mathrm {H} (X,Y)-\mathrm {H} (X)}$ and ${\displaystyle \mathrm {H} (X|Y)=\mathrm {H} (Y,X)-\mathrm {H} (Y)}$. Symmetry entails ${\displaystyle \mathrm {H} (X,Y)=\mathrm {H} (Y,X)}$. Subtracting the two equations implies Bayes' rule.

If ${\displaystyle Y}$ is conditionally independent of ${\displaystyle Z}$ given ${\displaystyle X}$ we have:

${\displaystyle \mathrm {H} (Y|X,Z)\,=\,\mathrm {H} (Y|X).}$

### Other properties

For any ${\displaystyle X}$ and ${\displaystyle Y}$:

{\displaystyle {\begin{aligned}\mathrm {H} (Y|X)&\leq \mathrm {H} (Y)\,\\\mathrm {H} (X,Y)&=\mathrm {H} (X|Y)+\mathrm {H} (Y|X)+\operatorname {I} (X;Y),\qquad \\\mathrm {H} (X,Y)&=\mathrm {H} (X)+\mathrm {H} (Y)-\operatorname {I} (X;Y),\,\\\operatorname {I} (X;Y)&\leq \mathrm {H} (X),\,\end{aligned}}}

where ${\displaystyle \operatorname {I} (X;Y)}$ is the mutual information between ${\displaystyle X}$ and ${\displaystyle Y}$.

For independent ${\displaystyle X}$ and ${\displaystyle Y}$:

${\displaystyle \mathrm {H} (Y|X)=\mathrm {H} (Y)}$ and ${\displaystyle \mathrm {H} (X|Y)=\mathrm {H} (X)\,}$

Although the specific-conditional entropy ${\displaystyle \mathrm {H} (X|Y=y)}$ can be either less or greater than ${\displaystyle \mathrm {H} (X)}$ for a given random variate ${\displaystyle y}$ of ${\displaystyle Y}$, ${\displaystyle \mathrm {H} (X|Y)}$ can never exceed ${\displaystyle \mathrm {H} (X)}$.

## Conditional differential entropy

### Definition

The above definition is for discrete random variables. The continuous version of discrete conditional entropy is called conditional differential (or continuous) entropy. Let ${\displaystyle X}$ and ${\displaystyle Y}$ be a continuous random variables with a joint probability density function ${\displaystyle f(x,y)}$. The differential conditional entropy ${\displaystyle h(X|Y)}$ is defined as[3]: 249

${\displaystyle h(X|Y)=-\int _{{\mathcal {X}},{\mathcal {Y}}}f(x,y)\log f(x|y)\,dxdy}$

(Eq.2)

### Properties

In contrast to the conditional entropy for discrete random variables, the conditional differential entropy may be negative.

As in the discrete case there is a chain rule for differential entropy:

${\displaystyle h(Y|X)\,=\,h(X,Y)-h(X)}$[3]: 253

Notice however that this rule may not be true if the involved differential entropies do not exist or are infinite.

Joint differential entropy is also used in the definition of the mutual information between continuous random variables:

${\displaystyle \operatorname {I} (X,Y)=h(X)-h(X|Y)=h(Y)-h(Y|X)}$

${\displaystyle h(X|Y)\leq h(X)}$ with equality if and only if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent.[3]: 253

### Relation to estimator error

The conditional differential entropy yields a lower bound on the expected squared error of an estimator. For any random variable ${\displaystyle X}$, observation ${\displaystyle Y}$ and estimator ${\displaystyle {\widehat {X}}}$ the following holds:[3]: 255

${\displaystyle \mathbb {E} \left[{\bigl (}X-{\widehat {X}}{(Y)}{\bigr )}^{2}\right]\geq {\frac {1}{2\pi e}}e^{2h(X|Y)}}$

This is related to the uncertainty principle from quantum mechanics.

## Generalization to quantum theory

In quantum information theory, the conditional entropy is generalized to the conditional quantum entropy. The latter can take negative values, unlike its classical counterpart.