Skip to content
Glacius
ProbabilityConcept reference

Entropy

Finite entropy is the probability-weighted average of each outcome’s surprisal.

On this page 8 sections
  1. Overview
  2. Entropy is the average surprise of outcomes drawn from a distribution
  3. Category counts define an empirical distribution after you divide by their total
  4. A zero-probability outcome contributes 0 by the convention 0log 0=0
  5. A closer look
  6. Key takeaway
  7. Sources & further reading
  8. Concept connections

01Entropy is the average surprise of outcomes drawn from a distribution#

Entropy is the average surprise of outcomes drawn from a distribution. It summarizes uncertainty before an outcome is observed. A distribution concentrated on one certain outcome has no uncertainty; a spread across several plausible outcomes can have more.

Entropy is the expected surprisal of a finite distribution. Find each outcome’s surprisal, then average using its own probability.

H(P)=ipilog2pi\begin{gathered}H(P)\\=-\sum_i p_i\log_2 p_i\end{gathered}

For masses 0.5,0.125,0.125,0.125,0.125, the first contribution is 0.5 bits. Each small outcome adds 0.375 bits, giving entropy 2 bits.

entropy: category width is target probability P; rectangle height is −log₂ P in bits.  P=(0.5, 0.125, 0.125, 0.125, 0.125); Q=(0.5, 0.125, 0.125, 0.125, 0.125).entropy: category width is target probability P; rectangle height is −log₂ P in bits.  P=(0.5, 0.125, 0.125, 0.125, 0.125); Q=(0.5, 0.125, 0.125, 0.125, 0.125).
Figure 1entropy: category width is target probability P; rectangle height is −log₂ P in bits. P=(0.5, 0.125, 0.125, 0.125, 0.125); Q=(0.5, 0.125, 0.125, 0.125, 0.125).
Link to this figure ↗Download SVGDownload PNG

For probabilities (1/2,1/4,1/4)(1/2,1/4,1/4), the surprises are (1,2,2)(1,2,2) bits. Weight each by how often that outcome occurs: 0.5(1)+0.25(2)+0.25(2)=1.50.5(1)+0.25(2)+0.25(2)=1.5 bits. Averaging the three surprises equally would incorrectly treat the categories as equally likely.

Check your reasoning

PMF masses: (0.5,0.125,0.125,0.25)(0.5, 0.125, 0.125, 0.25). Find entropy in bits.

Show answer and explanation
1.75

Positive-mass contributions: 0.5, 0.375, 0.375, 0.5 bits. Sum: 1.751.75 bits. Zero masses contribute 0.

02Category counts define an empirical distribution after you divide by their total#

Category counts define an empirical distribution after you divide by their total. Use those probabilities as weights, rather than assuming the categories are equally likely.

Entropy does not change when you rename the categories. It depends on how the probability is distributed.

Check your reasoning

Category counts: (2,2,4)(2, 2, 4). Use their empirical PMF. Find entropy in bits.

Show answer and explanation
1.5

Normalize the counts. Positive-mass contributions: 0.5, 0.5, 0.5 bits. Sum: 1.51.5 bits. Zero masses contribute 0.

03A zero-probability outcome contributes 0 by the convention 0log 0=0#

A zero-probability outcome contributes 0 by the convention 0log0=00\log 0=0. A distribution concentrated on one outcome has entropy 0.

Zero entropy means certainty under that distribution. A forecaster can be certain and wrong, so entropy alone cannot establish factual correctness.

Check your reasoning

PMF masses: (0.25,0.25,0.5,0)(0.25, 0.25, 0.5, 0). A draft treats a zero mass as an infinite entropy term. Correct the entropy in bits.

Show answer and explanation
1.5

Contributions: 0.5+0.5+0.5+0=1.5 bits.

04A closer look#

Entropy supplies a baseline expected log loss when a forecast matches the target distribution. It describes the stated distribution, not how confident a learner feels. A zero-probability category contributes zero to the expectation; it is never drawn from that distribution.

Key takeaway

Weight each surprisal by its probability, treat zero-mass terms as zero, and interpret the result as uncertainty.

  • Compute entropy of a finite probability distribution.

Sources & further reading

  1. [1]
  2. [2]
    Dive into Deep Learning §22.11Dive into Deep Learning §22.11 · Article

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Entropy.” Math behind ML. /learn/p-entropy