Information Theory

GATE Relevance: High

🎯 Learning Objectives

  • Compute entropy and interpret it as expected information content
  • Define and compute cross-entropy and KL divergence
  • Understand mutual information and its applications
  • Connect entropy to decision tree splitting (information gain)

1. Entropy

Shannon Entropy

H(X) = −∑i P(xi) log2 P(xi)

Measures the average uncertainty (or information content) of a random variable X. Units: bits (base 2) or nats (base e).

Key Properties

  • H(X) ≥ 0 (always non-negative)
  • H(X) = 0 iff X is deterministic
  • Maximum when X is uniform: H(X) = log2(n) for n outcomes
  • Convention: 0 log 0 = 0

Example 1 — Fair vs Biased Coin GATE Style

Fair coin: H = −(0.5 log2 0.5 + 0.5 log2 0.5) = 1 bit

Biased coin (P(H) = 0.9): H = −(0.9 log2 0.9 + 0.1 log2 0.1) ≈ 0.469 bits

Example 2 — Three Outcomes

P = (1/2, 1/4, 1/4). H = −(0.5 × −1 + 0.25 × −2 + 0.25 × −2) = 0.5 + 0.5 + 0.5 = 1.5 bits

2. Conditional Entropy

Conditional Entropy

H(Y|X) = ∑x P(x) H(Y|X=x) = −∑x,y P(x,y) log2 P(y|x)

Average remaining uncertainty about Y after observing X. Always: H(Y|X) ≤ H(Y).

3. Cross-Entropy

Cross-Entropy

H(P, Q) = −∑i P(xi) log Q(xi)

Measures the average number of bits needed to encode data from distribution P using a code optimized for distribution Q. Used as a loss function in neural networks and logistic regression.

H(P, Q) ≥ H(P), with equality iff P = Q. The "extra" bits are the KL divergence.

4. KL Divergence

Kullback-Leibler Divergence

DKL(P || Q) = ∑i P(xi) log (P(xi) / Q(xi))

Measures how much distribution Q differs from distribution P. Also called relative entropy.

KL Divergence is NOT Symmetric

DKL(P||Q) ≠ DKL(Q||P) in general. It is NOT a distance metric.

Relationship

H(P, Q) = H(P) + DKL(P || Q)

Cross-entropy = Entropy + KL Divergence

5. Mutual Information

Mutual Information

I(X; Y) = H(X) − H(X|Y) = H(Y) − H(Y|X) = H(X) + H(Y) − H(X, Y)

Measures the amount of information that X and Y share. I(X;Y) ≥ 0, with equality iff X and Y are independent.

6. Information Gain (Decision Trees)

Information Gain GATE Key Formula

IG(S, A) = H(S) − ∑v ∈ Values(A) (|Sv| / |S|) × H(Sv)

The reduction in entropy of target S after splitting on attribute A. ID3/C4.5 algorithms select the attribute with the highest information gain.

Example GATE Style

Dataset: 9 positive, 5 negative. H(S) = −(9/14) log2(9/14) − (5/14) log2(5/14) ≈ 0.940

Attribute Wind = {Weak, Strong}. Weak: 6+, 2−. Strong: 3+, 3−.

H(SWeak) = −(6/8)log(6/8) − (2/8)log(2/8) ≈ 0.811

H(SStrong) = −(3/6)log(3/6) − (3/6)log(3/6) = 1.0

IG(S, Wind) = 0.940 − (8/14)(0.811) − (6/14)(1.0) = 0.940 − 0.463 − 0.429 = 0.048

Summary

  • Entropy: H(X) measures uncertainty; max for uniform distribution
  • Cross-entropy: H(P,Q) — loss function for classification
  • KL divergence: DKL(P||Q) — asymmetric divergence measure
  • Mutual information: I(X;Y) = reduction in uncertainty
  • Information gain: entropy reduction when splitting on an attribute — used in decision trees