Self-Information and Bits
Derive logarithmic surprise from probability, compare bits and nats, interpret fractional ideal code lengths, handle zero-probability failures, and add conditional costs across sequences.
Self-information measures the surprise of one observed outcome relative to a stated probability model. A likely outcome carries little new information when it occurs; an unlikely outcome carries more. The logarithm makes independent information additive and gives the quantity an operational interpretation as an ideal code length.
Surprise Depends on Probability
Suppose an outcome has probability . Its self-information, also called surprisal, is
“The information in outcome x is negative log base b of the probability of x.” A smaller probability produces greater information because its logarithm is more negative before the minus sign is applied.
Three boundary behaviors agree with ordinary reasoning about surprise:
- if , then because the outcome was certain;
- if , then ;
- as approaches zero, grows without bound.
For a weather model with , observing rain carries
Observing no rain under the same model carries
Rain is more informative in this technical sense because the model considered it less likely. This statement depends on the model and does not say that rain is more important to every person or decision.
Exercise: Find the information in a certain event
How many bits of self-information does an event with probability carry?
Compute it first, then check your number.
HintUse log base two
Calculate .
SolutionCertainty carries zero surprise
Since , a certain event carries bits of self-information. Observing it resolves no uncertainty left by the model.
Why Information Uses a Logarithm
A useful numerical measure of surprise should behave in three ways:
- it should vary continuously as probability changes;
- a less probable outcome should carry more information; and
- independent outcomes should have additive information.
For independent outcomes and , . A logarithm converts this product into a sum:
Under mild regularity conditions, these requirements lead to a negative logarithm up to a positive choice of scale. The logarithm is therefore not an arbitrary decoration added to probability: it expresses how independent possibilities combine.
Two independent fair coin results have joint probability . Their information is bits, equal to one bit for each result. Ten independent fair coin results similarly carry ten bits.
Exercise: Add information across independent events
Two independent outcomes have probabilities and . How many bits of self-information does the pair carry?
Compute it first, then check your number.
HintAdd the two surprisals
The outcomes carry bits and bits separately.
SolutionIndependent surprisals add
The joint probability is , so the pair carries bits. Equivalently, add the separate costs: bits.
The Logarithm Base Sets the Unit
With base , information is measured in bits. Each bit corresponds to one binary distinction in an ideal description. With base , the unit is the nat. Base gives hartleys.
| Probability | Information in bits | Information in nats |
|---|---|---|
The units are converted by a constant factor:
Halving a probability always adds one bit:
An equation or loss reported without its logarithm base may still be useful, but its numerical unit is incomplete. Many mathematical and machine-learning libraries use natural logarithms, so their log losses are measured in nats unless converted.
Exercise: Calculate a rare outcome's information
An outcome has probability . How many bits of self-information does it carry?
Compute it first, then check your number.
HintWrite the probability as a power of two
.
SolutionThe outcome carries four bits
Since , bits. Four binary distinctions can identify one outcome among sixteen equally likely possibilities.
Ideal Code Length May Be Fractional
The probability gives
An isolated binary codeword cannot literally contain bits. The value is an ideal length. Prefix-free codes for individual symbols use whole-number lengths, while block codes and arithmetic coding can approach fractional average lengths over long sequences.
For example, a sequence of occurrences of outcomes that each receive probability has ideal total length
The sequence can use a whole number of bits while its average approaches bits per outcome. Information theory commonly makes statements about long-run or expected length rather than promising an exact fractional codeword for one symbol.
A Model Assigns the Surprise
Self-information is not a property of an outcome by itself. It is calculated from a probability distribution. If model assigns probability to an observed token, its cost is
If model assigns probability to the same observed token, its cost is
Model B pays three extra bits for that outcome. A model is therefore penalized strongly when it assigns little probability to what occurs. This is the local, one-outcome form of logarithmic loss.
Convert probabilities to ideal bit lengths
Change the probabilities and compare how rapidly code length grows near zero. Every value must lie strictly between zero and one.
Ready to run.
Exercise: Compare two predictive costs
Model A assigns probability to the observed outcome. Model B assigns probability . How many more bits does model B use for that outcome?
Compute it first, then check your number.
HintCalculate both surprisals
Compare with .
SolutionThe lower probability costs two extra bits
Model A pays bit and model B pays bits. Model B therefore pays additional bits for the observed outcome.
Zero Probability Creates Infinite Loss
If a model assigns to an outcome that occurs, then
The issue is not merely numerical. A zero probability says that the event is impossible under the model, so a code based on that model has not reserved a finite representation for it. In practice, probabilistic systems must handle support carefully. Smoothing, probability floors, or model structures with positive probability can prevent unintended zeros, although each choice changes the model and must be justified.
A zero-probability outcome under the true source distribution is different: it never occurs under that source and therefore contributes nothing to an average over source outcomes. Problems arise when the source can produce an outcome to which the predictive model assigns zero.
Exercise: Recognize a support failure
A source can produce symbol with positive probability, but a predictive model assigns . What logarithmic cost does the model incur when occurs?
Select one choice, then check.
HintApproach zero from above
As becomes smaller and positive, grows without bound.
SolutionAn observed zero-probability event has infinite log cost
The cost is in the limiting sense. The model's support fails to include an outcome that the source can produce.
Sequence Information Uses Conditional Probabilities
Independence is not required to calculate the information in a sequence. The probability chain rule writes
Taking a negative logarithm turns the product into a sum:
“The information in the whole sequence is the sum, over positions t, of the negative log probability of the observed symbol given the preceding symbols.” The notation means all sequence elements before position .
Suppose a model assigns
The sequence probability is . Its information is
which also equals bits from the three conditional predictions. This additive token-level form is the basis of autoregressive language-model log loss.
One Outcome and an Average Are Different
Self-information describes one realized outcome under a stated model. It does not measure semantic meaning, practical importance, truth, or usefulness. A random identifier may be highly surprising yet convey little useful structure, while a predictable warning may be extremely important to act upon.
Before observing an outcome, we can average its possible self-information values using their source probabilities. That expected surprise is entropy, the subject of the next lesson. Keeping the distinction clear prevents us from calling the surprise of one rare event “the entropy” and from confusing a model's local log loss with the source's average uncertainty.
Exercise: Distinguish surprisal from entropy
Which quantity describes the information in one observed outcome under a stated probability model?
Select one choice, then check.
HintOne outcome versus an expectation
Entropy is the source-probability-weighted average of the possible self-information values.
SolutionSelf-information belongs to one outcome
Self-information describes one observed outcome relative to a model. Entropy is the expected self-information over all outcomes under a source distribution.