George Buck · information theory
Entropy sounds abstract, but it answers a concrete question: on average, how many yes/no questions do I need to figure out what happened? One yes/no question is one bit. Here's the picture I use to make that click: for every outcome, draw a bar. Its width is how often it happens, and its height is how many questions it takes. The shaded area is the entropy.
I'm thinking of 1, 2, 3 or 4. I pick 1 half the time, 2 a quarter of the time, and 3 and 4 an eighth of the time each. The smart way to find it is to ask about the likeliest number first:
Notice the pattern. Each question cuts what's left in half, so an outcome you reach in 3 questions must have had a 1-in-8 chance: 2 × 2 × 2 = 8. Turned around, an outcome with probability p takes log₂(1/p) questions.
Here are my four numbers as bars. Drag the blue tabs under the axis to change how often each number comes up. Rare outcomes get tall (they take lots of questions) but thin (they hardly ever happen), so they don't add much shading.
Why the logarithm? Chances multiply (half of a half is a quarter) but questions add (one question plus one question is two). The log is the thing that turns multiplying into adding.
This is where entropy earns its keep. A spam filter has 20 emails, 10 spam and 10 not. Before asking anything, it's a coin flip: 1 bit of uncertainty. A good question splits the emails into piles that are each easy to call. The uncertainty left over is the shaded area of the two piles, each as wide as its share of the emails.
The drop from 1 bit to whatever is left is called information gain. It's exactly how a decision tree picks which question to ask next.