# Conditional entropy

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Conditional_entropy
> Markdown URL: https://mediated.wiki/source/Conditional_entropy.md
> Source: https://en.wikipedia.org/wiki/Conditional_entropy
> Source revision: 1343839568
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Measure of relative information in probability theory

[Venn diagram](/source/Venn_diagram) showing additive and subtractive relationships various [information measures](/source/Quantities_of_information) associated with correlated variables

        X

    {\displaystyle X}

 and

        Y

    {\displaystyle Y}

. The area contained by both circles is the [joint entropy](/source/Joint_entropy)

          H

        (
        X
        ,
        Y
        )

    {\displaystyle \mathrm {H} (X,Y)}

. The circle on the left (red and violet) is the [individual entropy](/source/Entropy_(information_theory))

          H

        (
        X
        )

    {\displaystyle \mathrm {H} (X)}

, with the red being the conditional entropy

          H

        (
        X

          |

        Y
        )

    {\displaystyle \mathrm {H} (X|Y)}

. The circle on the right (blue and violet) is

          H

        (
        Y
        )

    {\displaystyle \mathrm {H} (Y)}

, with the blue being

          H

        (
        Y

          |

        X
        )

    {\displaystyle \mathrm {H} (Y|X)}

. The violet is the [mutual information](/source/Mutual_information)

        I
        ⁡
        (
        X
        ;
        Y
        )

    {\displaystyle \operatorname {I} (X;Y)}

.

Information theory Entropy Differential entropy Conditional entropy Joint entropy Mutual information Directed information Conditional mutual information Relative entropy Entropy rate Limiting density of discrete points Asymptotic equipartition property Rate–distortion theory Shannon's source coding theorem Channel capacity Noisy-channel coding theorem Shannon–Hartley theorem v t e

In [information theory](/source/Information_theory), the **conditional entropy** quantifies the amount of information needed to describe the outcome of a [random variable](/source/Random_variable) Y {\displaystyle Y} given that the value of another random variable X {\displaystyle X} is known. Here, information is measured in [shannons](/source/Shannon_(unit)), [nats](/source/Nat_(unit)), or [hartleys](/source/Hartley_(unit)). The "entropy of Y {\displaystyle Y} conditioned on X {\displaystyle X} " is denoted as H ( Y | X ) {\displaystyle \mathrm {H} (Y|X)} .

## Definition

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

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

where X {\displaystyle {\mathcal {X}}} and Y {\displaystyle {\mathcal {Y}}} denote the [support sets](/source/Support_(mathematics)) of X {\displaystyle X} and Y {\displaystyle Y} .

*Note:* Here, the convention is that the expression 0 log ⁡ 0 {\displaystyle 0\log 0} should be treated as being equal to zero. This is because lim θ → 0 + θ log ⁡ θ = 0 {\displaystyle \lim _{\theta \to 0^{+}}\theta \,\log \theta =0} .[1]

Intuitively, notice that by definition of [expected value](/source/Expected_value) and of [conditional probability](/source/Conditional_Probability), H ( Y | X ) {\displaystyle \displaystyle H(Y|X)} can be written as H ( Y | X ) = E [ f ( X , Y ) ] {\displaystyle H(Y|X)=\mathbb {E} [f(X,Y)]} , where f {\displaystyle f} is defined as f ( x , y ) := − log ⁡ ( p ( x , y ) p ( x ) ) = − log ⁡ ( p ( y | x ) ) {\displaystyle \displaystyle f(x,y):=-\log \left({\frac {p(x,y)}{p(x)}}\right)=-\log(p(y|x))} . One can think of f {\displaystyle \displaystyle f} as associating each pair ( x , y ) {\displaystyle \displaystyle (x,y)} with a quantity measuring the information content of ( Y = y ) {\displaystyle \displaystyle (Y=y)} given ( X = x ) {\displaystyle \displaystyle (X=x)} . This quantity is directly related to the amount of information needed to describe the event ( Y = y ) {\displaystyle \displaystyle (Y=y)} given ( X = x ) {\displaystyle (X=x)} . Hence by computing the expected value of f {\displaystyle \displaystyle f} over all pairs of values ( x , y ) ∈ X × Y {\displaystyle (x,y)\in {\mathcal {X}}\times {\mathcal {Y}}} , the conditional entropy H ( Y | X ) {\displaystyle \displaystyle H(Y|X)} measures how much information, on average, the variable X {\displaystyle X} encodes about Y {\displaystyle Y} .

## Motivation

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

- H ( Y ) = ∑ y ∈ Y P r ( Y = y ) I ( y ) = − ∑ y ∈ Y p Y ( y ) log 2 ⁡ p Y ( y ) , {\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 I ⁡ ( y i ) {\displaystyle \operatorname {I} (y_{i})} is the [information content](/source/Information_content) of the [outcome](/source/Outcome_(probability)) of Y {\displaystyle Y} taking the value y i {\displaystyle y_{i}} . The entropy of Y {\displaystyle Y} conditioned on X {\displaystyle X} taking the value x {\displaystyle x} is defined by:

- H ( Y | X = x ) = − ∑ y ∈ Y Pr ( Y = y | X = x ) log 2 ⁡ Pr ( Y = y | X = x ) . {\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 H ( Y | X ) {\displaystyle \mathrm {H} (Y|X)} is the result of averaging H ( Y | X = x ) {\displaystyle \mathrm {H} (Y|X=x)} over all possible values x {\displaystyle x} that X {\displaystyle X} may take. Also, if the above sum is taken over a sample y 1 , … , y n {\displaystyle y_{1},\dots ,y_{n}} , the expected value E X [ H ( y 1 , … , y n ∣ X = x ) ] {\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](/source/Discrete_random_variable) X {\displaystyle X} with image X {\displaystyle {\mathcal {X}}} and Y {\displaystyle Y} with image Y {\displaystyle {\mathcal {Y}}} , the conditional entropy of Y {\displaystyle Y} given X {\displaystyle X} is defined as the [weighted sum](/source/Weight_function) of H ( Y | X = x ) {\displaystyle \mathrm {H} (Y|X=x)} for each possible value of x {\displaystyle x} , using p ( x ) {\displaystyle p(x)} as the weights:[3]: 15

- H ( Y | X ) ≡ ∑ x ∈ X p ( x ) H ( Y | X = x ) = − ∑ x ∈ X p ( x ) ∑ y ∈ Y p ( y | x ) log 2 p ( y | x ) = − ∑ x ∈ X , y ∈ Y p ( x ) p ( y | x ) log 2 p ( y | x ) = − ∑ x ∈ X , y ∈ Y p ( x ) p ( y | x ) log 2 ( p ( y | x ) p ( x ) p ( x ) ) = − ∑ x ∈ X , y ∈ Y p ( x , y ) log 2 ⁡ p ( x , y ) p ( x ) . {\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 _{2}\,p(y|x)\\&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}\,p(x)p(y|x)\,\log _{2}\,p(y|x)\\&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}\,p(x)p(y|x)\,\log _{2}\,\left(p(y|x){\frac {p(x)}{p(x)}}\right)\\&=-\sum _{x\in {\mathcal {X}},y\in {\mathcal {Y}}}p(x,y)\log _{2}{\frac {p(x,y)}{p(x)}}.\end{aligned}}}

## Properties

### Conditional entropy equals zero

- H ( Y | X ) = 0 {\displaystyle \mathrm {H} (Y|X)=0} [if and only if](/source/If_and_only_if) the value of Y {\displaystyle Y} is completely determined by the value of X {\displaystyle X} .

### Conditional entropy of independent random variables

Conversely, H ( Y | X ) = H ( Y ) {\displaystyle \mathrm {H} (Y|X)=\mathrm {H} (Y)} if and only if Y {\displaystyle Y} and X {\displaystyle X} are [independent random variables](/source/Independent_random_variables).

### Chain rule

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

- H ( Y | X ) = H ( X , Y ) − H ( X ) . {\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:

- H ( Y | X ) = ∑ x ∈ X , y ∈ Y p ( x , y ) log ⁡ ( p ( x ) p ( x , y ) ) = ∑ x ∈ X , y ∈ Y p ( x , y ) ( log ⁡ ( p ( x ) ) − log ⁡ ( p ( x , y ) ) ) = − ∑ x ∈ X , y ∈ Y p ( x , y ) log ⁡ ( p ( x , y ) ) + ∑ x ∈ X , y ∈ Y p ( x , y ) log ⁡ ( p ( x ) ) = H ( X , Y ) + ∑ x ∈ X p ( x ) log ⁡ ( p ( x ) ) = H ( X , Y ) − H ( X ) . {\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:

- H ( X 1 , X 2 , … , X n ) = ∑ i = 1 n H ( X i | X 1 , … , X i − 1 ) {\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](/source/Chain_rule_(probability)) in [probability theory](/source/Probability_theory), except that addition instead of multiplication is used.

### Bayes' rule

[Bayes' rule](/source/Bayes'_rule) for conditional entropy states

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

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

If Y {\displaystyle Y} is [conditionally independent](/source/Conditional_independence) of Z {\displaystyle Z} given X {\displaystyle X} we have:

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

### Other properties

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

- H ( Y | X ) ≤ H ( Y ) H ( X , Y ) = H ( X | Y ) + H ( Y | X ) + I ⁡ ( X ; Y ) , H ( X , Y ) = H ( X ) + H ( Y ) − I ⁡ ( X ; Y ) , I ⁡ ( X ; Y ) ≤ H ( X ) , {\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 I ⁡ ( X ; Y ) {\displaystyle \operatorname {I} (X;Y)} is the [mutual information](/source/Mutual_information) between X {\displaystyle X} and Y {\displaystyle Y} .

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

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

Although the specific-conditional entropy H ( X | Y = y ) {\displaystyle \mathrm {H} (X|Y=y)} can be either less or greater than H ( X ) {\displaystyle \mathrm {H} (X)} for a given [random variate](/source/Random_variate) y {\displaystyle y} of Y {\displaystyle Y} , H ( X | Y ) {\displaystyle \mathrm {H} (X|Y)} can never exceed H ( X ) {\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 X {\displaystyle X} and Y {\displaystyle Y} be a continuous random variables with a [joint probability density function](/source/Joint_probability_density_function) f ( x , y ) {\displaystyle f(x,y)} . The differential conditional entropy h ( X | Y ) {\displaystyle h(X|Y)} is defined as[3]: 249

- h ( X | Y ) = − ∫ X , Y f ( x , y ) log ⁡ f ( x | y ) d x d y {\displaystyle h(X|Y)=-\int _{{\mathcal {X}},{\mathcal {Y}}}f(x,y)\log f(x|y)\,dxdy} .

### 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:

- h ( Y | X ) = h ( X , Y ) − h ( X ) {\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](/source/Mutual_information) between continuous random variables:

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

- h ( X | Y ) ≤ h ( X ) {\displaystyle h(X|Y)\leq h(X)} with equality if and only if X {\displaystyle X} and Y {\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](/source/Estimator). For any Gaussian random variable X {\displaystyle X} , observation Y {\displaystyle Y} and estimator X ^ {\displaystyle {\widehat {X}}} the following holds:[3]: 255

- E [ ( X − X ^ ( Y ) ) 2 ] ≥ 1 2 π e e 2 h ( X | Y ) {\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](/source/Uncertainty_principle) from [quantum mechanics](/source/Quantum_mechanics).

## Generalization to quantum theory

In [quantum information theory](/source/Quantum_information_theory), the conditional entropy is generalized to the [conditional quantum entropy](/source/Conditional_quantum_entropy). The latter can take negative values, unlike its classical counterpart.

## See also

- [Entropy (information theory)](/source/Entropy_(information_theory))

- [Mutual information](/source/Mutual_information)

- [Conditional quantum entropy](/source/Conditional_quantum_entropy)

- [Variation of information](/source/Variation_of_information)

- [Entropy power inequality](/source/Entropy_power_inequality)

- [Likelihood function](/source/Likelihood_function)

## References

1. **[^](#cite_ref-1)** ["David MacKay: Information Theory, Pattern Recognition and Neural Networks: The Book"](http://www.inference.org.uk/mackay/itprnn/book.html). *www.inference.org.uk*. Retrieved 2019-10-25.

1. **[^](#cite_ref-2)** Hellman, M.; Raviv, J. (1970). "Probability of error, equivocation, and the Chernoff bound". *IEEE Transactions on Information Theory*. **16** (4): 368–372. [CiteSeerX](/source/CiteSeerX_(identifier)) [10.1.1.131.2865](https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.2865). [doi](/source/Doi_(identifier)):[10.1109/TIT.1970.1054466](https://doi.org/10.1109%2FTIT.1970.1054466).

1. ^ [***a***](#cite_ref-cover1991_3-0) [***b***](#cite_ref-cover1991_3-1) [***c***](#cite_ref-cover1991_3-2) [***d***](#cite_ref-cover1991_3-3) [***e***](#cite_ref-cover1991_3-4) [***f***](#cite_ref-cover1991_3-5) [***g***](#cite_ref-cover1991_3-6) [T. Cover](/source/Thomas_M._Cover); J. Thomas (1991). [*Elements of Information Theory*](https://archive.org/details/elementsofinform0000cove). Wiley. [ISBN](/source/ISBN_(identifier)) [0-471-06259-6](https://en.wikipedia.org/wiki/Special:BookSources/0-471-06259-6).

---
Adapted from the Wikipedia article [Conditional entropy](https://en.wikipedia.org/wiki/Conditional_entropy) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Conditional_entropy?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
