# 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 (X,Y)}$. The circle on the left (red and violet) is the individual entropy ${\displaystyle \mathrm (X)}$, with the red being the conditional entropy ${\displaystyle \mathrm (X|Y)}$. The circle on the right (blue and violet) is ${\displaystyle \mathrm (Y)}$, with the blue being ${\displaystyle \mathrm (Y|X)}$. The violet is the mutual information ${\displaystyle \operatorname (X;Y)}$.

In information theory, the conditional entropy (or equivocation) 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 (Y|X)}$.

## Definition

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

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

(Eq.1)

where ${\displaystyle {\mathcal }}$ and ${\displaystyle {\mathcal }}$ 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]

## Motivation

Let ${\displaystyle \mathrm (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 }}$ and ${\displaystyle {\mathcal }}$. Let ${\displaystyle Y}$ have probability mass function ${\displaystyle p_{(y)}}$. The unconditional entropy of ${\displaystyle Y}$ is calculated as ${\displaystyle \mathrm (Y):=\mathbb [\operatorname (Y)]}$, i.e.

${\displaystyle \mathrm (Y)=\sum _}}{\mathrm (Y=y)\,\mathrm (y)}=-\sum _}}(y)\log _(y)}},}$

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

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

${\displaystyle \mathrm (Y|X)}$ is the result of averaging ${\displaystyle \mathrm (Y|X=x)}$ over all possible values ${\displaystyle x}$ that ${\displaystyle X}$ may take.

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

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

## Properties

### Conditional entropy equals zero

${\displaystyle \mathrm (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 (Y|X)=\mathrm (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 (X,Y)}$, that is, we need ${\displaystyle \mathrm (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 (X)}$ bits of information. Once ${\displaystyle X}$ is known, we only need ${\displaystyle \mathrm (X,Y)-\mathrm (X)}$ bits to describe the state of the whole system. This quantity is exactly ${\displaystyle \mathrm (Y|X)}$, which gives the chain rule of conditional entropy:

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

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

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

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

${\displaystyle \mathrm (X_,X_,\ldots ,X_)=\sum _^\mathrm (X_|X_,\ldots ,X_)}$[2]: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 (Y|X)\,=\,\mathrm (X|Y)-\mathrm (X)+\mathrm (Y).}$

Proof. ${\displaystyle \mathrm (Y|X)=\mathrm (X,Y)-\mathrm (X)}$ and ${\displaystyle \mathrm (X|Y)=\mathrm (Y,X)-\mathrm (Y)}$. Symmetry entails ${\displaystyle \mathrm (X,Y)=\mathrm (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 (Y|X,Z)\,=\,\mathrm (Y|X).}$

### Other properties

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

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

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

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

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

Although the specific-conditional entropy ${\displaystyle \mathrm (X|Y=y)}$ can be either less or greater than ${\displaystyle \mathrm (X)}$ for a given random variate ${\displaystyle y}$ of ${\displaystyle Y}$, ${\displaystyle \mathrm (X|Y)}$ can never exceed ${\displaystyle \mathrm (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[2]:249

${\displaystyle h(X|Y)=-\int _{{\mathcal },{\mathcal }}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)}$[2]: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 (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.[2]: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 }}$ the following holds:[2]:255

${\displaystyle \mathbb \left[{\bigl (}X-{\widehat }{(Y)}{\bigr )}^\right]\geq {\frac }e^}$

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.