1.3.18 · D3 · HinglishProbability & Statistics

Worked examplesEntropy and KL divergence

2,770 words13 min read↑ Read in English

1.3.18 · D3 · AI-ML › Probability & Statistics › Entropy and KL divergence

Yeh page parent topic ki workbook hai. Hum formulas ko scratch se re-derive nahi karenge — balki hum har tarah ke inputs ko dhundhenge jo yeh formulas encounter kar sakti hain, aur unhe last decimal tak work out karenge. Isko ek checklist ki tarah socho: is page ke baad, koi bhi probability distribution tumhe kabhi surprise nahi karni chahiye.

Shuru karne se pehle, un do symbols ko ek baar plain words mein phir se anchor karte hain jo hum baar baar use karenge.

Neeche har jagah, bina base ke matlab hai (answers bits mein) jab tak hum "nats" na bolein, jis case mein yeh natural log hai.


Scenario matrix

Yeh is topic ki problems mein milne wale sabhi cases ka poora landscape hai. Neeche har worked example ko us cell ke saath tag kiya gaya hai jo woh cover karta hai, aur milke yeh poori grid fill karte hain.

Cell Kya special hai isme Covered by
A. Uniform sabhi outcomes equally likely → entropy hits its maximum Ex 1
B. Skewed / biased ek outcome dominate karta hai → entropy shrinks Ex 2
C. Degenerate (certain) ek probability , baaki → entropy , aur trap Ex 2, Ex 3
D. KL both directions vs → asymmetry made concrete Ex 4
E. KL degenerate kuch jahan → divergence blows up to Ex 5
F. Identity → KL (sanity floor) Ex 4 (check)
G. Cross-entropy = KL + H one-hot label vs prediction → classification loss Ex 6
H. Limiting behaviour continuous knob ya : entropy ka peak kahan hai? Ex 7
I. Word problem real-world compression / surprise story Ex 8
J. Exam twist additivity + independence ek hi shot mein combine karo Ex 9
Figure — Entropy and KL divergence

Upar wala blue curve (isko binary entropy curve kaho) woh map hai jis par hum baar baar return karte rahenge. Isko left se right padho: edges aur par curve floor ko touch karta hai (certainty, cell C), aur middle mein par yeh bit ki ceiling tak pahunchta hai (cell A). Cell B slopes par rehta hai; cell H poore curve ki shape hai.


Cell A — uniform maximum


Cells B & C — skew aur zero-probability trap


Cell C phir se — true floor


Cells D & F — KL dono directions mein aur identity floor


Cell E — divergence explode ho jaati hai


Cell G — cross-entropy, KL, aur classification loss


Cell H — limiting behaviour, peak kahan hai


Cell I — ek word problem


Cell J — exam twist


Yahan se kahan jaate hain

  • Waste-bits idea generalize hota hai: KL F-divergences family ka ek member hai, aur uska symmetrized cousin hai Jensen-Shannon Divergence.
  • Constraints ke subject mein maximum entropy wali distribution choose karna hai Maximum Entropy Principle.
  • Deep generative models mein, ek prior ke against KL term minimize karna Variational Autoencoders aur Evidence Lower Bound (ELBO) ka core hai.
  • Decision trees entropy drop par split karte hain jise Information Gain kehte hain.
Recall Self-test (jawab dene ke baad reveal karo)

Fair 4-sided die entropy ::: bits () Loaded coin entropy ::: bits for ::: bits Same but reversed ::: bits (asymmetric!) KL jab ek aisi event ko assign kare jisme ho ::: Cross-entropy of , ::: nats Weather for ::: bits Us weather ka KL to uniform ::: bits Joint entropy of fair 4-die + fair coin ::: bits