Information, Entropy, Relative Entropy, and Mutual Information
Fundamental definitions, Relationships between them, and Chain rules
History
In the early 20th century, laying copper wires and building radio infrastructure was very expensive, and physical bandwidth (range of frequencies a wire could reliably carry) was a strictly finite resource. Telecom companies needed to maximize their return on investment, so engineers had to figure out how much “payload” (actually useful bits) these lines were truly carrying, instead of just measuring electrical pulses.
People were designing different physical systems to transmit information (like a simple on-off based Morse code system, or a decoder for 10 different voltage levels), and they needed way to compare these systems to find out which one had the maximum throughput while minimizing physical costs.
| Engineering pressure | Why it mattered |
|---|---|
| Throughput | This means customer messages per unit time, and mattered because telecoms charged per word. |
| Pulse rate | Long physical wires blurred different pulses together, so sending 50 pulses per second was easier on the wire than 100. |
| Symbol alphabet size | The wires were very noisy, so it was easier to tell the difference between on and off than between many voltage levels. |
The physical wire worked exactly the same whether it was transmitting speech or a string of random numbers, so we couldn’t use human semantics (like abbreviations) to design a system. The natural next idea was to base it on the likelihood of the symbols used.
Hartley (1928) said: if a source emits symbols from an alphabet of size , there are possible messages. But since cost and time scale linearly with message length, we would like our information measure to do so too, so the amount of information transferred is better represented as (taking the log of ).
IntuitionPhysical interpretation
Here Hartley’s idea was that any system that needs to handle sending 2 digit numbers (in base 10, so n=2 and D=10) repeatedly, would have 100 possible messages so would need some physical system capable of distinguishing 100 different states, which in binary hardware requires exactly on/off pulses for every 2 digit number that the system would transmit.
This measure assumed every symbol is equally likely, but real sources like
English are not, there are many more e’s than z’s (or in the Hartley example, 00 is probably more likely than 73), and you could design
schemes to take advantage of these asymmetries in the possibilities using
the statistical structure.
Shannon (1948) exploited this by making information a function of the probability of symbols instead of alphabet size.
Information (surprise)
Setup: Let be a discrete random variable mapping a physical action (like pressing a telegraph key) to a specific symbol in an alphabet (26 letters of English + space + punctuation). Its likelihood is given by the probability mass function .
Motivation: Because physical wires ignore human semantics, every symbol’s
“information” depends on how predictable it is, expected symbols (like E at
) carry less information than rare symbols (like Z at
). To quantify this, we define as the measure of the
“surprise”, or information, contained in a single event such as seeing the
letter E.
| Component | Detail |
|---|---|
| Signature | |
| Domain | does not take the symbol as its input (to avoid tying the math to the application, and to allow relabelling to a different scenario), it takes only the probability of that symbol, . |
| Codomain | The set of positive reals, intuitively in some inversely proportional way. |
The three conditions we need on
- Additivity on independent events: for all . Learning two unrelated facts should yield the sum of their information. Without this there is no well-defined information rate per symbol, and a message of doubled length would not have doubled cost.
- Monotonically decreasing in : for . Being told a symbol you already knew in your shared prior must cost nothing, so (this also comes out of additivity, since ), and rarer outcomes are more informative.
- Normalization: . This is just to decide on a unit for information: observing an event with 50% probability (a fair coin flip) provides exactly 1 bit.
TheoremUniqueness of the surprise function
If a function satisfies Additivity and Monotonicity, then for some constant . Adding Normalization fixes the base of the logarithm, resulting in exactly
ProofAdditivity gives the rationals, monotonicity gives the reals
Converting multiplication into addition using Cauchy’s equation
The additivity rule operates on probabilities (fractions multiplying together). We can simplify this by mapping the domain to the non-negative real numbers using the substitution . Then we define a new function , which means . Because , our multiplicative rule for turns into a purely additive rule for , known as Cauchy’s functional equation:
Also, because goes down as gets larger (monotonicity), our new function must go up as gets larger. Let . Since is increasing and , must be .
Solving for integers
Using the new rule, . By simple induction, for any integer :
Solving for rationals
Let be a rational number. Using the integer rule from above and the observation that :
Divide both sides by :
Using just additivity, we have a closed form of the function for every rational number.
Solving for reals using monotonicity
For irrational numbers like , without the monotonicity rule could have been a wildly scattered, discontinuous fractal on the irrationals that still satisfies additivity (this can be proven using a Hamel basis, a concept from linear algebra).
Because we declared must be monotonic (smoothly increasing without jumping around), we can take any irrational number and “squeeze” it between two rational numbers and with . Because and , as we squeeze and infinitely close to , they both converge to . Therefore:
Back-substituting and normalizing
Undo the initial substitution to get back to :
Finally, apply the normalization rule :
Substituting back in:
So is not just a convenient measure of information, given our three basic logical constraints, it is the only possible measure.
∎
IntuitionPhysical interpretation
In the Hartley scheme, transmitting 3-letter English words required a fixed bits for every single word () because all sequences were treated uniformly. Under Shannon’s definition we now have a way to replace this uniform representation with a variable-length prefix code based on distributions:
A word like “THE” appears frequently (). Its surprise is bits. The physical line should send this using only pulses.
A valid sequence like “SPY” might appear with . Its surprise is bits, justifying pulses.
Where this goes next: We now have a measure for the information contained in a single keystroke. But while building a radio tower we care about the overall long-term behaviour of a message source, not a single keystroke, so we need a single number to represent the average information rate of the entire system. That is the average information over all keystrokes, using the expectation from statistics:
Substituting the term we derived gives the expected surprise from the message source, fundamental enough to be given its own name: Entropy.
Entropy
Setup: Let be a discrete random variable mapping the event of a human pressing a telegraph machine key to one symbol in our alphabet , with pmf . This is the same one as for self-information, since the message source is just a machine that rolls the random variable over and over again ().
Motivation: We want the expected surprise from any generic keystroke, so entropy ranges over the entire alphabet. This means that unlike self-information , which takes a single probability (a number between 0 and 1) and outputs the surprise of one specific symbol, entropy is a functional: it takes the entire probability distribution of the random variable and maps it to a single number representing the average surprise.
| Component | Detail |
|---|---|
| Signature | |
| Domain | The entire probability mass function of the source, giving the full blueprint like E is 12%, Z is 0.01%, T is 9%, etc. |
| Codomain | A single non-negative real number, the average bits of surprise per keystroke. |
FormulaEntropy
ConventionSymbols of zero probability
If we run into we use the limit convention from calculus. If a symbol is physically impossible for the machine to print, it will never be observed on the wire, and therefore contributes exactly 0 bits of surprise to the long-term average.
Properties
- Non-negativity : .
You can never have negative entropy. Because every probability is a
fraction between 0 and 1, the fraction is always 1 or
greater. Equality holds only if the outcome is deterministic, the telegraph
machine is broken and only prints
E(, and all other letters ). - Maximum entropy bound : . Entropy hits its absolute mathematical ceiling when every single symbol in the alphabet is equally likely (a uniform distribution). If you have a 32-key telegraph machine and the operator presses keys completely at random, you have maximum uncertainty of . Any structure in a language would make it lower.
From one source to a channel: the pair
We now have a mathematical model for a single message source . But a real communication system is not just one isolated source. It is connected to a copper wire with electrical interference, which terminates at a receiver. Because of this noise, the receiver experiences a new physical event (e.g. hearing a distorted click on the sounder).
flowchart LR O[Operator presses key] --> X["X: sent symbol, x in alphabet"] X -->|noisy copper wire| Y["Y: received symbol, y in alphabet"] Y --> T[Receiver's tape]
We define a new discrete random variable , which maps this received physical event to a symbol in the receiver’s alphabet (usually, but not always, the same 26-letter alphabet as the sender’s).
To evaluate the communication system as a whole, factoring in the source behaviour, the wire noise, and the receiver observation all at once, we can treat the sender’s input and the receiver’s output as a single combined physical event. This makes a single vector-valued random variable , mapping the dual physical event (the sender pressing a key and the receiver observing a click) to a pair of symbols in the combined alphabet .
The statistical blueprint of this entire system is the joint probability mass function : the likelihood that the sender transmits AND the receiver simultaneously gets , capturing both the sender’s vocabulary habits and the wire’s physical noise profile.
Joint entropy
Motivation: Joint entropy measures the expected surprise of the entire end-to-end system.
| Component | Detail |
|---|---|
| Signature | |
| Domain | The entire joint probability distribution, the complete grid of probabilities for every possible sent-and-received pair. |
| Codomain | A single non-negative real number, the average bits of surprise generated by any complete transmission cycle. |
Since we are treating the pair as a single, slightly more complex telegraph machine, we reuse the exact same expected-value framework we used for . The surprise of a specific pair occurring is simply . To find the average over both the sent and received alphabets, in code we would have to use a double summation to iterate through the grid:
FormulaJoint entropy
ExampleThe double summation code
def joint_entropy(p): # p[x][y] = P(X=x, Y=y) total = 0.0 for i in range(len(p)): for j in range(len(p[i])): prob = p[i][j] if prob > 0: # the 0 log 0 = 0 convention total -= prob * log2(prob) return totalWhere this goes next: Now suppose we want to isolate the effect of the noisy wire itself. One way is to freeze the sender’s variable, so that we know which symbol was transmitted, the uncertainty left over in the system is then about which symbol pops out at the receiver’s end, based on wire noise only. In a perfect, noiseless wire, knowing means you perfectly know , so the leftover uncertainty is exactly 0 bits, but in a real wire there may be flips due to static.
Conditional entropy
Like the other entropies, this is a functional too, but it operates on a different set of probabilities.
| Component | Detail |
|---|---|
| Signature | |
| Domain | Two things are needed, the marginal probability of the sender (how often they send E), and the conditional probability matrix of the wire which is the physical noise profile: if E is sent, what is the probability of receiving E, T, Z, etc. |
| Codomain | A single non-negative real number, the average bits of surprise introduced strictly by the noise in the wire during any one transmission. |
For any specific symbol such as the letter E, the entropy of the receiver’s
outcomes, using the standard entropy formula, is:
But since we cannot just look at E, we need to average this leftover
uncertainty across every symbol the sender could possibly transmit, weighting
each one by how often the sender actually transmits it, :
FormulaConditional entropy
DerivationExpanding to the direct form
Substituting the inner entropy:
Since does not depend on , we can pull it inside the inner summation:
Applying the rule of conditional probability, :
IntuitionWhy the two probabilities inside the formula’s RHS differ
We use the joint probability on the outside as the statistical weight, because we are averaging over the real-world occurrence of both events happening together. But inside the logarithm we strictly use the conditional probability , because the actual “surprise” we are measuring is strictly the surprise of happening given that has already happened.
Chain rule of entropy (two variables)
Since joint entropy is for the sender and the wire system as a whole, and the individual components both have entropies we have discussed, there is a natural relation:
TheoremChain rule of entropy
Symmetry of the chain rule
Because joint entropy looks at the whole system from the outside, it doesn’t matter which side you start on:
Consider the case where the sender uses a very complex, erratic language
(high entropy, say 10 bits per symbol), but the receiver is a broken machine
that only prints two symbols, A or B (low entropy, max 1 bit per symbol). We
would need:
This makes sense from either direction:
| Direction | Reading |
|---|---|
| Forward : | The sender has 1,024 different keys on their complex keyboard ( bits). When they press a key, the signal travels down the wire to the broken 2-symbol receiver. Because the receiver only has two outputs, the wire acts like a massive funnel. If you know exactly which of the 1,024 keys the sender pressed, guessing which of the 2 receiver keys pops out is relatively easy, so the uncertainty added strictly by the wire’s mechanism, , is very small. |
| Backward : | If the broken receiver machine prints an A ( bit), you now have to guess what the sender originally typed. Because the wire funnelled 1,024 different inputs down into just 2 outputs, a massive amount of information was destroyed. Knowing that A printed tells you almost nothing about which of the 1,024 keys was pressed, so your leftover surprise is very high. |
ProofBy direct evaluation
Starting from the definition of joint entropy:
Applying the conditional probability rule to the probability inside the logarithm:
In the first term, does not contain a . Therefore, if we sum the joint probability over all possible values of , the simply collapses out by marginalization, leaving only the marginal probability :
Replacing with the terms we know:
Alternative proof. Take the expectation of both sides of the basic logarithmic probability rule .
∎
WarningConditional entropy is directional
As discussed above, . The amount of noise the wire adds to the sent signal is not the same number as the receiver’s confusion about the sent signal. They are measuring uncertainty from two different directions.
With a third variable
The chain rule holds even if we add a third variable to the system (which could be a secondary sensor monitoring the wire):
Relative entropy (Kullback–Leibler distance)
Motivation: Now that we have a model capable of representing the telegraph system, we design a compression code for it to minimize cost to the telecom companies. One logical way to do this is to assign the shortest codes to the most common letters, based on a blueprint pmf for the alphabet. However, in reality your sender may be transmitting messages in a different language, or talking about a specific topic, meaning their true probability blueprint is . Because your compression code is optimized for but reality follows , your system is inefficient and transmits wasted bits. We need a term that measures these wasted bits arising from different assumptions about the underlying language.
Relative entropy, also called the Kullback–Leibler distance and denoted , measures this exact inefficiency.
| Component | Detail |
|---|---|
| Signature | |
| Domain | A pair of probability mass functions from the space of all possible distributions over the alphabet. |
| Codomain | An extended non-negative real number: the exact penalty, in extra bits per keystroke, you pay for assuming when the truth is . |
WarningAn impossible symbol costs infinity
If assumes a letter is physically impossible () but it actually happens in reality (), the penalty is infinite. This is why the codomain is rather than .
Why something like would not work
Imagine two operators:
- Operator P types
A99% of the time, andB1% of the time. - Operator Q types
A1% of the time, andB99% of the time.
Because both operators have the exact same ratio of predictability (just flipped), their total average uncertainty is identical: bits, so any difference-of-entropies measure reports zero penalty.
But say Operator Q’s codebook assigns a tiny 1-bit code to B and a massive
7-bit code to A. If you force Operator P (who almost only types A) to use
Operator Q’s codebook, Operator P will be forced to send a massive 7-bit code 99%
of the time, causing a high number of wasted bits.
Building the right measure
To find the real penalty, we must look at the cost of a single keystroke, and then average it out.
| Codebook built for | Code length assigned to |
|---|---|
| The true reality (ideal) | |
| The false assumption (actual) |
The extra wasted bits for typing that specific symbol is actual cost minus ideal cost:
Using logarithm rules, this simplifies to:
This fraction is the exact number of extra bits you waste every single time you type the letter , but you only type the letter according to the true reality of the system, . Therefore, to find the average total penalty of using the wrong codebook, we weight that per-keystroke penalty by the true probability and sum over the whole alphabet:
FormulaRelative entropy (Kullback–Leibler distance)
WarningNot a true distance
While we often call this a “distance” between two distributions, it is not a true geometric metric, because it is not symmetric: . Optimizing for English but transmitting French carries a different bit penalty than optimizing for French but transmitting English.
Mutual information
Motivation (the severed-wire view): In our communication system with sender and receiver , suppose we cut the wire and look at the system. Because the wire is cut, and have absolutely nothing to do with each other, they are independent, and the probability blueprint of this severed system is simply the product of their individual probabilities, .
One way to measure the ability of the physical connection to communicate the information of to is to measure how far away the connected system is from being a severed system. “Far away” implies distance, so we can use the relative entropy tool to measure the distance between the true, connected reality and the false, severed assumption .
Motivation (the engineer’s view): If the wire is cut, the engineer has to compress, transmit, and store and as two completely independent streams of data: sending takes bits and sending takes bits. But if the wire is connected, is largely just a noisy echo of , instead of sending from scratch, they can just send the differences (the noise), and storing them together as a joint system only takes bits. The “penalty” of assuming independence is the wasted bandwidth or hard drive space from failing to exploit their physical correlation.
This exact distance from independence is called mutual information, .
| Component | Detail |
|---|---|
| Signature | |
| Domain | Like joint entropy, the entire joint probability distribution of the communication system. |
| Codomain | A non-negative real number: the average actual amount of useful bits shared between and per keystroke. If the wire is dead (zero correlation); the higher the number, the more perfectly synced the two ends are. |
Substituting the connected reality for , and the severed assumption for , in relative entropy:
FormulaMutual information
DerivationFrom the definition to the entropy-difference form
While the formula above defines what mutual information is, we can expand the logarithm to reveal exactly how it relates to the uncertainty of the sender and receiver.
Apply the conditional probability rule ; the on top cancels the on the bottom:
In the second term, because does not care about , we can marginalize (collapse) the joint probability by summing over , so turns back into the marginal probability :
Replacing the terms:
IntuitionWhat the difference is measuring
is your total uncertainty about what the sender typed before you look at the receiver’s tape. is the leftover confusion you still have after you look at the receiver’s tape. So the difference is the exact mathematical amount by which your uncertainty was reduced — the amount of knowledge successfully gained.
Equivalent forms
is perfectly symmetrical, so says exactly as much about as says about :
| Form | Reading |
|---|---|
| Sender’s uncertainty, minus what’s left after seeing the receiver’s tape. | |
| From the receiver’s perspective: the useful info equals the total bits received, minus the bits that were generated purely by the wire’s noise. | |
| Using joint entropy: the sum of the two isolated systems, minus their combined total uncertainty, which subtracts out the double-counted overlap. | |
| Since . The amount of information a variable shares with itself is exactly its entire entropy, which is also why entropy is called self-information. |
Chain rule for entropy ( variables)
Motivation: Imagine calculating the total uncertainty of an entire telegraph
message of length . You don’t just add up the independent uncertainty of each
letter, because letters depend on each other (grammar, spelling, the letter Q may be unlikely but after Q appears, the letter U is very likely). The total
uncertainty of a book is the uncertainty of the 1st letter, plus the remaining
uncertainty of the 2nd letter given you know the 1st, plus the uncertainty of the
3rd given you know the first two, and so on.
TheoremChain rule for entropy
Let be drawn according to a joint probability distribution . The joint entropy of the entire collection is the sum of the conditional entropies:
ProofBy direct evaluation
We start with the definition of the joint entropy for variables, which is the expected value of their joint surprise:
From basic probability, any joint distribution can be perfectly factored using the chain rule of probability, . Substitute this into the logarithm:
Because the logarithm of a product is the sum of the logarithms, we pull the sum outside:
We swap the order of summations. For each -th term, any variable with does not appear inside the logarithm, so we can marginalize those future variables out, leaving only the variables up to :
This inner sum is the exact definition of conditional entropy, so it simplifies perfectly to:
∎
Conditional mutual information
Motivation: Suppose a sender wants to transmit a secret message to a receiver. To protect the transmission across an untrusted wire, the sender generates a purely random one-time pad key and broadcasts the ciphertext .
flowchart TD X[Secret Plaintext X] --> Y[Ciphertext Y = X ⊕ Z] Z[Shared Key Z] --> Y
Without the key, looking at the ciphertext tells you absolutely nothing about the message ().
We want to know: Given that we observe the key , how much information does the ciphertext now reveal about the plaintext ?
| Component | Detail |
|---|---|
| Signature | |
| Domain | The joint probability distribution across the three variables. |
| Codomain | The number of bits of information shared between and within the context of knowing . |
Following the standard definition of mutual information (baseline uncertainty minus remaining uncertainty), we evaluate how observing collapses our remaining doubt about once is fixed:
FormulaConditional mutual information
That is: the remaining uncertainty of knowing only the key , minus the uncertainty of knowing both the ciphertext and key .
In the one-time pad:
- (knowing the key alone leaves completely unknown).
- (knowing key and ciphertext lets you reconstruct perfectly).
- Thus, .
Chain rule for mutual information
Motivation: Instead of one sender, imagine a sequence of different sensors () transmitting data to a single central receiver hub . We want to calculate the total amount of useful information the entire sensor array successfully shared with the hub.
TheoremChain rule for mutual information
The total mutual information between the sequence and is the sum of the individual mutual informations, each conditioned on the sensors that came before it:
ProofExpand into entropies, then apply the entropy chain rule twice
Expand into entropies:
Apply the entropy chain rule to both terms:
Combine the two sums:
The bracketed term is exactly the definition of conditional mutual information:
∎
IntuitionNo double-counting correlated sensors
If sensors observe the same physical environment, their raw readings often overlap. A naive sum severely overcounts because multiple sensors report redundant information about the hub .
The chain rule accounts for information sequentially where each sensor only gets credit for the fresh, non-redundant insight it provides about beyond what previous sensors already disclosed.
2-sensor scenario:
-
Let be whether a server room is on fire (, assuming equal prior odds).
-
Sensor is an optical smoke detector that detects the fire perfectly: .
-
Sensor is a thermal heat sensor that also detects the fire perfectly: .
- Sensor 1 alone: .
Observing completely resolves whether the room is on fire. - Sensor 2 in context: .
Because already identified the fire state, provides zero new information about , even though by itself has .
Applying the chain rule:
The chain rule gives us the true joint information () by stripping away redundancy, avoiding the naive sum of of non-existent certainty.
Chain rule for relative entropy
Motivation: Recall our compression engineer from earlier. They built a codebook for the entire sender–receiver system based on a false blueprint , when reality was actually . The total penalty paid in wasted bits is . We can split this penalty into two distinct physical failures:
- The penalty from misunderstanding the sender’s language ().
- The penalty from misunderstanding the noise profile of the wire ().
To measure the latter, we define conditional relative entropy, : the average distance between the true physical noise profile and the assumed noise profile, weighted by how often the sender actually transmits each symbol.
FormulaConditional relative entropy
IntuitionPaying for wire modeling errors only where traffic actually flows
If you misjudge the channel noise for a specific input , how much does it cost you? That depends on how often you actually transmit .
For a fixed transmitted symbol , the channel introduces noise according to the true transition distribution , but your receiver codebook expects . The inefficiency for that specific input is the standard KL divergence between the two output distributions:
To get the overall penalty across the entire wire, take the expected value over reality’s input traffic :
TheoremChain rule for relative entropy
The total penalty of the joint system is simply the penalty of the sender plus the penalty of the wire:
ProofFactor both blueprints, split the log, marginalize
Expand the joint relative entropy definition:
Apply the probability chain rule to both reality and assumption :
Use logarithm rules to split the fraction into the marginal part and the conditional part:
In the first sum, marginalize out (since the log term doesn’t depend on ); keep the second sum as is:
These are exactly the definitions of marginal relative entropy and conditional relative entropy:
∎
Summary
| Quantity | Formula | Reads as |
|---|---|---|
| Surprise | Surprise of one specific symbol. | |
| Entropy | Average bits of surprise per keystroke. | |
| Joint entropy | Average surprise of the full across source and wire. | |
| Conditional entropy | Bits of surprise contributed strictly by the wire. | |
| Relative entropy | Wasted bits from coding for when reality is . | |
| Mutual information | Useful bits shared per keystroke / distance from a severed wire. | |
| Conditional MI | New bits gives about beyond what already gave. |
Identities:
- and neither is symmetric.