Intro to Information Theory¶
"If a tree falls in the forest and no one is around to hear it, does it make a sound?"
Most likely, you are reading this article because you are curious and expect to learn something new. But what does it even mean to know something? Usually, when we think of knowledge, we think of truth, facts, or information.
A useful place to start defining knowledge is a simple observation: if you already knew the entire content of this article word for word, you wouldn't gain any new knowledge by reading it again. Likewise, if you reread a novel whose plot you already have memorized, the information you gain from the plot is virtually zero. How much you learn from an observation depends on how surprised you are by it.
Let's push this further: if a tree falls in a forest, how do you know that it actually happened? One way to frame this is to view the tree as an entity that communicates information to you when it falls. If you're standing next to it, you know it fell because light scatters off the falling trunk and into your eyes—just as the light from this screen carries the words of this article to you.
Signals and Observers¶
The falling tree generates a burst of physical signals: sound waves, vibrations through the ground, displaced air, and reflected light. Each of these signals carries potential information about the event, yet for that event to be known, at least one of those signals must be received and processed by another entity.
If no observer is present, the physical phenomena still occur—pressure waves still propagate through the air and disturb molecules. What doesn't happen is the transfer of knowledge. The signals exist, but they are never received or decoded into an update of anyone's beliefs. This draws a crisp line between physical phenomena and knowledge: physical processes happen independently of observation, whereas knowledge requires a receiver.
When we ask whether a falling tree "makes a sound," we're really conflating two different questions:
- Do compression waves propagate through the air when a tree falls? (A physics question.)
- Is the information carried by those waves received, processed, and converted into knowledge? (An epistemological question.)
The answer to the first is clearly yes—the physics occurs regardless of who is listening. The answer to the second depends on the presence of a receiver capable of interpreting those signals. This distinction points directly to the core idea of information: a measurable reduction in a receiver's uncertainty about a source.
A basic idea in communication theory is that information can be treated very much like a physical quantity such as mass or energyClaude Shannon
To turn this intuition into mathematics, we want a function that quantifies how much information a receiver gains upon observing an event whose probability they previously believed to be $p$.
Defining Information¶
Let us define the information content of an event using a function $\I$ of its probability $p = P(X = x)$:
$\I(p) = f(p)$, for some function $f : (0, 1] \rightarrow [0, \infty)$
What properties must $\I$ satisfy to match our intuition about surprise and knowledge?
$\I : (0, 1] \rightarrow [0, \infty)$
- Certainty yields zero information: $\I(1) = 0$. If an outcome has 100% probability, we already knew it would happen, so observing it teaches us nothing new.
- Rarer outcomes carry more information: $\I(p)$ is strictly decreasing as $p$ increases. The less probable an outcome, the more surprising it is—and as $p \to 0^+$, $\I(p) \to \infty$, because witnessing something we considered impossible forces an unbounded revision of our beliefs.
- Information is non-negative: $\I(p) \ge 0$. There is no such thing as "negative surprise"—observing an event cannot make you less informed than before.
- Information is continuous: $\I(p)$ is continuous on $(0, 1]$. A small change in an event's probability should produce only a small change in how surprising it is.
- Information is additive for independent events: If $A$ and $B$ are independent, then $P(A \cap B) = P(A)\,P(B)$, and observing both should yield the sum of their individual surprises: $$\I(A \cap B) = \I(A) + \I(B)$$
Finding $f$¶
Because independent events satisfy $P(A \cap B) = P(A) \cdot P(B)$, the additivity axiom requires:
$$f(x \cdot y) = f(x) + f(y) \quad \text{for all } x, y \in (0, 1]$$
This is a classic form of Cauchy's functional equation. The only continuous, non-trivial functions that turn multiplication into addition are logarithms:
$$f(p) = K \ln(p)$$
for some constant $K$. Notice what our remaining axioms tell us about $K$:
- $f(1) = K \ln(1) = 0$ holds automatically for any $K$.
- Since $\ln(p) \le 0$ for $p \in (0, 1]$, requiring $f(p) \ge 0$ and strictly decreasing forces $K < 0$.
Crucially, any negative constant $K$ works—and changing $K$ is algebraically identical to changing the base of the logarithm, since $K \ln(p) = -\log_b(p)$ with base $b = e^{-1/K} > 1$. Choosing $K = -1$ for a given base $b$ gives us the canonical definition.
Self-Information¶
$$\I(p) = -\log_b(p) = \log_b\!\left(\frac{1}{p}\right)$$
This quantity is known as Shannon information or self-information, named after Claude Shannon, who formalized Information Theory in his landmark 1948 paper.
Here is what $\I(p)$ looks like for three common choices of base $b$:
Why does $\I(p)$ scale with the choice of logarithm base? Just as length can be measured in meters or feet without changing the underlying distance, the base of the logarithm simply chooses the units of information:
- Base 2 ($\log_2$): Measures information in bits (binary digits), the natural unit for yes/no questions and digital computing.
- Base $e$ ($\ln$): Measures information in nats, widely used in statistical mechanics, calculus, and machine learning.
- Base 10 ($\log_{10}$): Measures information in Hartleys (or digits), occasionally used in telecommunications and engineering.
In the rest of this article we'll work in bits ($\log_2$).
Uncertainty and Surprise¶
Thinking of information as surprise rather than static facts reveals something deeper. When we treat the world around us as an information source, we never possess complete knowledge of what will happen next. Because we cannot predict the future with 100% certainty, real-world observations are inherently uncertain, and we need a way to quantify both the surprise of a single outcome and our overall uncertainty before we observe it.
Flipping Coins¶
Suppose we make a bet: I flip a coin and ask you to call the outcome ahead of time. If you're right, I double your wager.
If you bet on Tails, how confident should you feel? For a fair coin, $P(\text{Tails}) = \tfrac{1}{2}$—a 50% chance you're right.
Now suppose that before taking your money, I flip the coin 8 times and show you the sequence of outcomes:
$$x = (\text{H}, \text{H}, \text{T}, \text{H}, \text{T}, \text{H}, \text{H}, \text{H})$$
Would you still bet on Tails? Intuitively, probably not: out of 8 flips, only 2 came up Tails, hinting that the coin might be biased toward Heads. Of course, it's completely possible that a fair coin just happened to produce 6 Heads in 8 flips—try flipping 8 fair coins below and see how often lopsided runs show up by chance:
Heads: 0
Observed: 0%
Tails: 0
Observed: 0%
Sequence History
| Trial | Sequence | H / T Split |
|---|
Let's use self-information to measure how surprising our sequence "HHTHTHHH" is under three different prior beliefs about the coin:
- Absolute certainty in Tails ($P(\text{T}) = 1,\; P(\text{H}) = 0$): The very first Heads conveys $\I(0) = \infty$ surprise—our belief said Heads was impossible, forcing us to abandon that model immediately.
- A fair coin ($P(\text{H}) = P(\text{T}) = \tfrac{1}{2}$):
Each flip carries $\I(\tfrac{1}{2}) = -\log_2(\tfrac{1}{2}) = 1$ bit of information. Because independent surprises add, any specific sequence of 8 fair flips—whether
"HHTHTHHH"or"HHHHHHHH"—carries: $$\I(\text{HHTHTHHH}) = 8 \times \I\!\left(\tfrac{1}{2}\right) = 8 \text{ bits}$$ - A biased coin matching our sample ($P(\text{H}) = \tfrac{6}{8} = \tfrac{3}{4},\; P(\text{T}) = \tfrac{2}{8} = \tfrac{1}{4}$): Now a Heads is expected and carries only $\I(\tfrac{3}{4}) = -\log_2(\tfrac{3}{4}) \approx 0.415$ bits, whereas a rarer Tails carries $\I(\tfrac{1}{4}) = -\log_2(\tfrac{1}{4}) = 2$ bits. Across 6 Heads and 2 Tails, the sequence carries: $$\I(\text{HHTHTHHH}) = 6 \cdot \I\!\left(\tfrac{3}{4}\right) + 2 \cdot \I\!\left(\tfrac{1}{4}\right) \approx 6(0.415) + 2(2) \approx 6.49 \text{ bits}$$
Notice that 6.49 bits is less than 8 bits! A biased coin is more predictable than a fair coin, so its typical outcomes carry less surprise. This highlights a crucial principle: how much information an observation carries depends on your probability model of the source.
Now consider all $2^8 = 256$ possible 8-flip sequences. If we treat each sequence as our empirical estimate of the coin's bias and bet on its more frequent side, how surprised would we be if the 9th flip lands on that majority side?
That next-flip surprise is $\I(p_{\max}) = -\log_2(\max(p_H, p_T))$. For "HHTHTHHH", $p_{\max} = \tfrac{6}{8}$, giving $\I(\tfrac{6}{8}) \approx 0.4$ bits. The grid below maps this value across all 256 sequences:
Look at the extremes of those 256 sequences:
- At the top-left,
"HHHHHHHH"(and"TTTTTTTT"at the bottom-right) has $\I(p_{\max}) = 0.0$ bits: if that were the coin's true distribution ($P(\text{Heads}) = 1$), seeing another Heads on the 9th flip would carry zero surprise. - Across the middle band—every balanced 4H / 4T split—$p_{\max} = \tfrac{1}{2}$ gives $\I(p_{\max}) = 1.0$ bit: maximum uncertainty about the next flip.
If we're betting on a coin, what we really want is a single number summarizing how unpredictable the entire distribution is—not just the surprise of one lucky or unlucky outcome, but the average surprise we should expect before we flip.
Before defining that number, let's build intuition from a second angle: how many yes/no questions does it take to eliminate uncertainty?
The Guessing Game¶
Suppose I pick a random letter from the 26-letter English alphabet. If you identify it within 6 guesses, I'll double your bet. Every time you guess wrong, I'll tell you whether my secret letter comes before (left of) or after (right of) your guess.
Should you play? Six guesses out of 26 letters might sound tight, yet this game is completely rigged in your favor: with the right strategy, you are guaranteed to win in at most 5 guesses (and only 4 guesses on average). Try a few rounds below:
If you always guess the midpoint of the remaining range, you cut the search space in half on every step—a classic binary search tree. Each halving delivers 1 bit of information, reducing 26 possibilities to 13, then 7, then 4, then 2, then 1.
Because $\log_2(26) \approx 4.70$ bits, you need at most $\lceil \log_2(26) \rceil = 5$ guesses in the worst case—and since hitting the secret letter early ends the round, the average over all 26 letters is exactly 4.0 guesses. That's why a 6-guess wager is an automatic win.
Now ask the same question for a much larger alphabet—say, roughly 50,000 Chinese characters. How many guesses does binary search need? Without playing a single round, our logarithm tells us immediately:
$$\lceil \log_2(50{,}000) \rceil = 16 \text{ guesses}$$
Nearly two thousand times as many symbols, yet only 11 extra guesses—because uncertainty grows logarithmically with the number of equally likely possibilities.
That covers the uniform case, where every symbol has probability $\tfrac{1}{N}$. But what if the outcomes are not equally likely—like a biased coin, or letter frequencies in real English prose where E appears far more often than Q? To summarize the average uncertainty of any probability distribution in one number, we need entropy.
Shannon Entropy¶
Let $X$ be a discrete random variable taking values in $\{x_1, x_2, \dots, x_n\}$ with probabilities $p_i = P(X = x_i)$. We want a function $H(X)$ that measures the average uncertainty (or expected surprise) of $X$.
Building directly on self-information, we expect $H(X)$ to satisfy:
$0 \le H(X) \le \log_2(n)$ (in bits)
- Zero at certainty: $H(X) = 0$ if and only if one outcome is guaranteed ($p_k = 1$, and all other $p_i = 0$). When there is no uncertainty, observing $X$ yields zero new information.
- Maximized at uniformity: $H(X)$ reaches its maximum, $\log_2(n)$, when every outcome is equally likely ($p_i = \tfrac{1}{n}$). For a binary outcome like a coin ($n = 2$), the maximum is $\log_2(2) = 1$ bit; for a uniform English letter ($n = 26$), it is $\log_2(26) \approx 4.70$ bits.
- Non-negativity: $H(X) \ge 0$. Expected surprise can never be negative.
- Continuity: $H(X)$ varies smoothly with the probabilities $p_1, \dots, p_n$—a small shift in the distribution produces only a small change in entropy.
- Additivity for independent variables: If $X$ and $Y$ are independent random variables, their joint entropy is the sum of their individual entropies: $$H(X, Y) = H(X) + H(Y)$$
How do we construct $H(X)$ from self-information $\I(p_i) = -\log_2(p_i)$? Simply by taking its expected value—the probability-weighted average of the surprise across all possible outcomes:
$$H(X) = \mathbb{E}[\I(X)] = \sum_{i=1}^{n} p_i\,\I(p_i) = -\sum_{i=1}^{n} p_i \log_2(p_i)$$
(with the convention $0 \log_2 0 = 0$, since $\lim_{p \to 0^+} p \log_2 p = 0$—impossible outcomes contribute zero expected surprise).
Check this formula on our coin example, where $P(\text{Heads}) = p$ and $P(\text{Tails}) = 1 - p$. This gives the binary entropy function:
$$H(p) = -p \log_2(p) - (1 - p)\log_2(1 - p)$$
- Deterministic coin ($p = 0$ or $p = 1$): $H(p) = 0$ bits per flip.
- Fair coin ($p = 0.5$): $H(0.5) = -0.5(-1) - 0.5(-1) = 1.0$ bit per flip—peak uncertainty.
- Our biased coin ($p = 0.75$): $H(0.75) = -0.75\log_2(0.75) - 0.25\log_2(0.25) \approx 0.811$ bits per flip. Over 8 independent flips, the expected information is $8 \times 0.811 \approx 6.49$ bits—matching the exact figure we calculated earlier for
"HHTHTHHH"!
Look at that symmetric arch: entropy vanishes whenever we already know what the coin will do ($p = 0$ or $p = 1$), and peaks at $p = 0.5$ when both outcomes are equally plausible. In this sense, entropy is the amount of potential information we expect to receive before we observe a system—and equally, the fundamental lower bound on the average number of yes/no questions required to pin down its state.
Conclusion¶
We started with an old riddle—whether a falling tree makes a sound if no one is around to hear it—and ended up with a mathematical language for knowledge and uncertainty:
- Signals vs. knowledge: Physical events happen independently of observers, but information as knowledge requires a receiver whose uncertainty is reduced by a signal.
- Self-information: Requiring a continuous, non-negative, additive measure of surprise uniquely leads to $\I(p) = -\log_b(p)$, where the base $b$ simply picks our unit of measurement (bits, nats, or Hartleys).
- Shannon entropy: Averaging self-information across a probability distribution gives $H(X) = -\sum_i p_i \log_2(p_i)$—capturing how unpredictable a source is, why a fair coin carries more average information than a biased one, and why 16 binary questions suffice to find one symbol among 50,000.
Returning to the forest: physics accounts for the compression waves traveling through the air, while information theory formalizes what it means for a receiver to learn from them.
Up Next: Part 2 — Encoding & Channels¶
So far we've treated bits as an abstract measure of surprise and binary questions. In Part 2, we'll turn entropy into an engineering tool: stepping inside Shannon's communication channel to explore the Source Coding Theorem, prefix-free codes, why $H(X)$ sets the hard floor on lossless data compression, and what happens when noise enters the channel.
Further Reading¶
- Claude E. Shannon (1948), A Mathematical Theory of Communication
- Thomas M. Cover & Joy A. Thomas, Elements of Information Theory (Stanford Lecture Notes)