Module 7 · 11 min read · Free chapter
Information theory, channel capacity and error-control coding
Entropy is the average information per symbol and sets the limit for compression; Huffman coding gets close to it. A channel's capacity is the highest rate at which errors can be made arbitrarily rare; for a noisy channel of bandwidth B it is B log₂(1 + S/N). Hamming codes correct single errors, and CRC detects burst errors in data frames.
Start from zero: how much can a channel carry?
Engineers once believed that the only way to make a noisy link reliable was to slow it down: repeat each bit many times, and errors become rare, but the useful rate falls towards zero.
In 1948 Claude Shannon showed this was wrong. Every channel has a capacity, a maximum rate set by its bandwidth and noise. Below that rate, clever coding can make errors as rare as we like, without slowing to zero. Above it, nothing works.
Shannon also gave a way to measure information itself, the entropy of a source, which sets how far data can be compressed. Together these ideas founded information theory, which underlies ZIP files, mobile networks and deep-space links.
This chapter covers entropy and source coding, channel capacity, and the first practical error-control codes: Hamming codes and the CRC used in every Ethernet frame.
Why it matters. Entropy, Huffman coding, Shannon capacity and Hamming-code numericals are steady scorers in GATE EC and ESE papers.
Information and entropy
A message tells you more when it is surprising. "The sun rose today" tells you almost nothing, while "it snowed in Chennai" tells you a lot. Shannon measured the information in an event of probability as
A certain event, , carries zero information. A fair coin toss, , carries exactly 1 bit.
A source emits symbols with probabilities . Its entropy is the average information per symbol:
Entropy is largest when all symbols are equally likely, . Any bias towards some symbols makes the source more predictable and lowers .
For a binary source with probabilities and , the binary entropy function is
It is 0 at and , and peaks at 1 bit when . If the source emits symbols per second, its information rate is bits per second.
Worked example. A source emits four symbols with probabilities . Then bits/symbol, less than the 2 bits of an equally likely source.
Why it matters. Entropy calculations are the most common information-theory questions, and they set the limit for the compression in the next section.
Source coding and Huffman codes
To send a source efficiently, give short codewords to common symbols and long ones to rare symbols, as Morse code does with E (a single dot). The average codeword length is
where is the length of the codeword for symbol . Shannon's source coding theorem says no uniquely decodable code can do better than the entropy: . The coding efficiency is .
A prefix code, in which no codeword is the start of another, can be decoded instantly without separators. Huffman coding builds the best possible prefix code:
- List the symbols by probability.
- Merge the two least likely into one node whose probability is their sum.
- Repeat until one node remains.
- Read each codeword by labelling the branches 0 and 1 from the root.
Worked example. For probabilities , Huffman gives codewords 0, 10, 110 and 111. Then bits, equal to , so . This happens whenever all probabilities are powers of .
Shannon–Fano coding splits the list into two halves of nearly equal probability and repeats. It is simple but not always optimal.
Why it matters. "Build a Huffman code and find its efficiency" is one of the most frequent information-theory numericals in GATE and ESE.
Mutual information and channel capacity
A channel takes an input and gives an output , with some uncertainty because of noise. The conditional entropy is the uncertainty left about the input after seeing the output. The information that actually got through is the mutual information:
It is never negative, and it is zero if the output tells nothing about the input. The channel capacity is the largest value of over all possible input probabilities.
The classic example is the binary symmetric channel (BSC). Each bit arrives correctly with probability and flipped with probability . Its capacity, reached with equally likely inputs, is
At the channel is perfect and . At the output is pure chance and . Interestingly, also gives : every bit is flipped, so the receiver just inverts them.
Shannon's channel coding theorem says that if the information rate is below , codes exist that make the error probability as small as desired. Above , no code can.
Worked example. A BSC has . Then , so bits per use. At most about 53 useful bits can get through per 100 bits sent.
Why it matters. BSC capacity and the meaning of mutual information are standard GATE questions, and they explain why coding adds redundancy.
The Shannon–Hartley capacity
For a continuous channel of bandwidth with additive white Gaussian noise, Shannon found the capacity in closed form:
Here is the signal-to-noise power ratio as a plain number, with . The formula shows the two resources of communication. Capacity grows linearly with bandwidth but only logarithmically with power, so doubling power adds only about bits per second at high SNR.
Widening the bandwidth also lets in more noise. As grows without limit, capacity does not grow forever; it approaches
Writing at the limit gives the famous Shannon limit: reliable communication at any rate needs , or about dB. Modern turbo and LDPC codes, used in 4G and 5G, come within a fraction of a dB of this limit.
The ratio is the best possible spectral efficiency. It explains why high-order QAM is used only when SNR is high.
Worked example. A telephone channel has kHz and SNR 30 dB, which is 1,000. Then kb/s. Dial-up modems at 33.6 kb/s were close to this limit.
Why it matters. Shannon–Hartley calculations, especially with dB-to-ratio conversion, appear in almost every GATE EC paper.
Error-control codes: Hamming codes and CRC
Shannon proved good codes exist; engineers had to build them. The simplest useful family is the linear block code. An code takes data bits and adds parity bits, each a modulo-2 sum of some data bits. The code rate is .
The power of a code depends on its minimum Hamming distance , the fewest bit positions in which any two codewords differ. A code with distance can
Hamming codes have and for an integer , with , so they correct any single error. The (7, 4) Hamming code adds 3 parity bits to 4 data bits, at rate .
Decoding uses the parity-check matrix . The receiver computes the syndrome from the received word . A zero syndrome means no error was detected. For a Hamming code, a non-zero syndrome equals the column of at the position of the error, so the receiver flips that bit.
For error detection on long frames, networks use the cyclic redundancy check (CRC). The message, treated as a polynomial and shifted left by bits, is divided modulo 2 by a generator polynomial of degree . The -bit remainder is appended.
The receiver divides again and checks for a zero remainder. A good CRC detects all single and double errors, all odd numbers of errors and all bursts of length or less. Ethernet uses a 32-bit CRC.
Worked example. A code has . It can detect up to 4 errors or correct up to 2.
Why it matters. Detection and correction capability from , Hamming code parameters and syndrome decoding are routine GATE questions.
Descriptive lens
Written papers ask about this topic in four ways:
- Define information, entropy and information rate, and compute them for a given source.
- Construct a Huffman or Shannon–Fano code and find its efficiency and redundancy.
- Explain mutual information and channel capacity, for the binary symmetric channel and the AWGN channel, including the Shannon limit.
- Explain linear block codes, Hamming codes, syndrome decoding and CRC with an example.
Practice questions (our own, not previous-year questions).
- A source emits five symbols with probabilities 0.4, 0.2, 0.2, 0.1 and 0.1. Find its entropy, construct a Huffman code and find the coding efficiency. (15 marks)
- State the Shannon–Hartley theorem. Show that capacity approaches as bandwidth grows, and derive the Shannon limit on . (15 marks)
- For the (7, 4) Hamming code, explain how a single error is located using the syndrome. Why is CRC preferred for error detection in data networks? (10 marks)
Answer plan for question 1.
- Compute bits.
- Merge 0.1 and 0.1 into 0.2, then two 0.2 nodes into 0.4, then the remaining 0.2 and the original 0.4 into 0.6, then 0.4 and 0.6.
- Read the codeword lengths 2, 2, 2, 3 and 3 from the tree.
- Find bits.
- Conclude that .
Quick revision
- Information bits, and entropy .
- Maximum entropy is for equally likely symbols; binary entropy peaks at 1 bit at .
- Information rate is .
- Source coding: and ; Huffman merges the two least likely symbols.
- Mutual information ; capacity is its maximum.
- BSC capacity is , zero at .
- Shannon–Hartley: , tending to as .
- Shannon limit: dB.
- A code detects errors and corrects .
- Hamming codes: , , ; CRC detects bursts up to its degree.