skip to content

Information Theory

Entropy as the floor no lossless coder beats, the coders that approach it, channel capacity, and error detection versus correction. Interviewers probe it whenever size or reliability is at stake.

part ofComputer science fundamentalsoverview, primer and where to startread it →
on this pageshow

explore

questions

95 · 5 sections

What does the Shannon entropy of an event log's status field, measured in bits, actually tell you?

level: juniorimportance: must knowfreq 62%
basics
~20 s

Shannon entropy is the average surprisal of a field's values in bits: the sum of p times log2(1/p) over every value. It measures how uncertain the next value is, not how many distinct values exist.

open as a page

In information terms, an alert that fires in one minute out of 1024 carries ten bits of surprisal - what does that number mean?

level: juniorimportance: must knowfreq 62%
basics
~20 s

Ten bits is the surprisal of an outcome with probability 1/1024, since -log2(1/1024) = 10. One bit is the uncertainty resolved by one fair yes/no answer, so rarer outcomes carry more bits and a certain one carries zero.

open as a page

How does the chain rule H(X,Y) = H(X) + H(Y|X) price storing both columns of a routing log?

level: middleimportance: must knowfreq 48%
basics
~20 s

The chain rule prices a column pair as the first column's entropy plus whatever surprise the second still holds: H(X,Y) = H(X) + H(Y|X). Storing both together therefore never costs more than storing each separately, and usually costs less.

open as a page

What does a conditional entropy H(data centre | region) of 0.54 bits tell you about a two-column routing log?

level: middleimportance: must knowfreq 55%
basics
~20 s

Conditional entropy H(data centre | region) is the data-centre uncertainty left, on average, once the region is known. At 0.54 bits against 2 bits unconditioned, the region nearly fixes the data centre, but not completely.

open as a page

A candidate fraud signal shows zero mutual information with the fraud label — what does that tell you?

level: middleimportance: must knowfreq 58%
basics
~20 s

Zero mutual information means the signal and the label are independent in the distribution you measured: observing one removes none of the other's uncertainty. The reading is symmetric, it is an estimate, and it says nothing about the signal's value alongside other signals.

open as a page

A compression tool claims it makes every possible input file smaller — why is that claim impossible?

level: juniorimportance: must knowfreq 68%
basics
~20 s

Lossless compression must be reversible, so distinct inputs need distinct outputs. There are more n-bit inputs than shorter strings, so no map can shrink them all; a scheme that shrinks one input must expand another.

open as a page

Why does an archival tier re-compressing already-compressed or encrypted blocks get output slightly larger than the input?

level: middleimportance: must knowfreq 46%
basics
~20 s

Already-compressed and encrypted blocks have no repeated sequences and a near-uniform byte distribution, so the coder finds nothing to exploit and emits at least as much as it read, plus headers — a few bytes of growth per block.

open as a page

Which test tells you whether a prefix code exists with codeword lengths of 1, 2, 3, 3 and 3 bits?

level: middleimportance: must knowfreq 48%
basics
~20 s

Kraft's inequality: sum two to the minus each codeword length and compare with 1. For 1, 2, 3, 3 and 3 that sum is 1.125, above the budget, so no prefix code has those lengths.

open as a page

A binary envelope packs variable-length field tags back to back with no separator bits - why must those tag codewords be prefix-free?

level: middleimportance: must knowfreq 62%
basics
~20 s

Prefix-free means no codeword is the opening of another, so a decoder reading bit by bit knows a symbol has ended the instant it recognises one. Without that property it must look ahead or carry explicit lengths and separators.

open as a page

What guarantee does a stored-raw fallback block give a lossless container, and what does it cost?

level: middleimportance: should knowfreq 37%
basics
~20 s

A stored-raw block lets the writer emit a block's original bytes whenever coding them would be bigger, so worst-case expansion is capped by that block's small header rather than by the coder's behaviour — usually a small fraction of a percent.

open as a page

Run-length encoding replaces repeats with count-symbol pairs, so on what input does it make the output larger?

level: juniorimportance: must knowfreq 66%
basics
~20 s

Run-length encoding expands any input whose symbols rarely repeat: a single symbol still costs a count plus the symbol, so alternating bytes double in size. It pays only when the average run is longer than one pair.

open as a page

How does an arithmetic coder turn a whole message into a single subinterval of [0,1)?

level: middleimportance: must knowfreq 50%
basics
~20 s

An arithmetic coder starts with [0,1) and narrows it once per symbol, keeping the slice whose width is that symbol's probability. The final interval's width is the message's probability, and a number inside it identifies the whole message.

open as a page

How does a sliding-window compressor encode a repeated byte sequence as a length-distance back-reference?

level: middleimportance: must knowfreq 65%
basics
~20 s

A sliding-window compressor keeps the most recent N bytes it has already produced as its window. When the next bytes repeat something inside that window, it emits a pair of numbers, a distance back and a match length, instead of the bytes.

open as a page

How does Huffman coding build a code tree from a table of next-hop identifier frequencies?

level: middleimportance: must knowfreq 65%
basics
~20 s

Huffman coding repeatedly removes the two lowest-frequency trees and joins them under a new node weighted by their sum, until one tree remains. Each symbol's code is its root-to-leaf path, so rare symbols sink deepest and frequent ones stay shallow.

open as a page

The Burrows-Wheeler transform and move-to-front emit as many symbols as they consume, so what do they buy a compressor?

level: middleimportance: must knowfreq 55%
basics
~20 s

Nothing by themselves — they remove no bytes at all. They reshape the symbol distribution so that the entropy coder behind them, which is the stage that actually removes bits, meets a far more skewed and predictable stream.

open as a page

A preview pipeline offers a lossy encoder for every stored artifact; which payload classes must refuse it, and why?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Anything whose value is its exact bits must stay lossless: executables, archives, source, ledgers, and anything later checked by a digest or signature. Lossy fits terminal media a human tolerates approximately, never the master copy everything else is derived from.

open as a page

How does the bit depth of a recorder covering a fixed input range set the size of its worst-case quantization error?

level: middleimportance: must knowfreq 68%
basics
~20 s

Bit depth b splits a fixed range R into 2^b levels, so the uniform step is R divided by 2^b and round-to-nearest keeps every in-range sample within half a step. Each added bit halves the step and drops the error floor by about 6 dB.

open as a page

A capture is quantized, gain-adjusted, then quantized again at the same bit depth; when does the second pass add error?

level: seniorimportance: must knowfreq 55%
basics
~20 s

Re-rounding values that already sit on the same grid changes nothing. Any gain change, resample or range change moves the grid under them, so each such pass can add another half step, and the coarsest stage in the chain dominates the total.

open as a page

For a fidelity budget D, what does the rate-distortion function R(D) actually claim about any encoder?

level: seniorimportance: must knowfreq 44%
basics
~20 s

R(D) is the lowest average rate, in bits per source symbol, at which a source can be reproduced with average distortion at most D under a chosen distortion measure. It is a bound no scheme beats, non-increasing and convex, so extra bits buy steadily less.

open as a page

In a recorder that maps a fixed input range onto b bits, why does clipping fail differently from ordinary rounding error?

level: juniorimportance: should knowfreq 48%
basics
~20 s

Rounding error is bounded by half a quantization step and sits at a fixed low level. Clipping is unbounded: samples outside the input range flatten onto the endpoint, producing signal-correlated distortion that extra bits cannot reduce.

open as a page

A single parity bit is appended to each data word: which corruptions does a parity recheck catch, and which slip through?

level: juniorimportance: must knowfreq 62%
basics
~20 s

A parity recheck catches every odd number of flipped bits in the codeword and misses every even number. It cannot say which bit flipped, cannot repair anything, and is blind to bits that were reordered rather than flipped.

open as a page

A noisy link has a channel capacity of 0.53 bits per channel use - what does that number promise and what does it forbid?

level: middleimportance: must knowfreq 60%
basics
~20 s

Channel capacity is a reliable-rate ceiling. Any code carrying fewer than 0.53 data bits per channel use can be made as close to error-free as you like by using long enough blocks; no code above that rate can, however much redundancy it adds.

open as a page

On a binary symmetric channel with crossover probability p, what does p predict about a thousand-bit block over a radio link?

level: middleimportance: must knowfreq 62%
basics
~20 s

A binary symmetric channel flips each transmitted bit independently with probability p, and the receiver cannot see which bits changed. With p = 0.001 a thousand-bit block averages one flip, yet only about 37 percent of blocks arrive clean.

open as a page

In a binary erasure channel the receiver sees which positions vanished; why is that cheaper to repair than a flip?

level: middleimportance: must knowfreq 56%
basics
~20 s

Repair has two halves: finding the damaged position and fixing its value. An erasure hands you the position for free, so only the value must be recovered, which takes roughly half the redundancy a silent flip of unknown location needs.

open as a page

Which corruptions slip past a one's-complement additive checksum on a configuration blob pushed over a serial link?

level: middleimportance: must knowfreq 54%
basics
~20 s

An additive sum is unchanged by reordering whole words, by inserting or deleting a word that adds nothing, and by two changes that cancel each other. Any change confined to a single word is caught, which is what makes the holes structural rather than random.

open as a page