About this book
Information Theory, Inference, and Learning Algorithms is a textbook by David MacKay, a physicist who spent most of his working life at the University of Cambridge. Cambridge University Press published it in 2003. From the start, MacKay arranged for the full text to be readable free on his website, while the printed book stayed on sale. The book is long, over six hundred pages, and full of exercises, worked solutions, diagrams and asides. It grew out of courses MacKay taught to Cambridge students in physics and engineering through the 1990s.
The book is built on a conviction that three subjects usually taught apart belong together. Information theory, founded by Claude Shannon in 1948, asks how to compress data and how to send it reliably over noisy channels. Statistical inference asks how to reason from data to conclusions under uncertainty. Machine learning asks how a system can improve its predictions from experience. MacKay argues that all three rest on probability, that their central problems are versions of one another, and that a student who learns them together understands each more deeply.
The question the book sets out to answer can be put plainly. What is information, how do we measure it, how do we use it efficiently, and how do we learn from it? The answers turn out to be linked. To compress a message well you need a good probabilistic model of the source, which is a learning problem. To decode a message sent through noise you must infer what was sent from what was received, which is an inference problem. To compare learning models fairly you can ask how well each compresses the data, which is a coding problem. MacKay takes these links seriously and builds the book around them.
The intended reader is an undergraduate or graduate student in science or engineering, or a working researcher, who is comfortable with calculus, linear algebra and basic probability. The book does not assume prior knowledge of information theory or machine learning. It is meant to be worked through, not only read. MacKay places exercises inside the text and asks the reader to attempt them before continuing, and he marks which exercises are most important and how hard each is.
The tone is unusual for a textbook. MacKay is witty, opinionated and practical. He uses puzzles, games and small surprises to teach, and he is willing to argue, especially for the Bayesian approach to inference and against what he saw as muddled statistical habits. He also cares about whether ideas work in practice. The book does not stop at theorems about what is possible. It shows how real codes and real algorithms achieve close to the theoretical limits, and it includes careful discussion of computation.
The author
Physicist and teacher
David John Cameron MacKay was born in 1967 in England. He studied natural sciences, specialising in physics, at Trinity College, Cambridge. He then went to the California Institute of Technology for his doctorate, in the programme in computation and neural systems, where his adviser was John Hopfield, the physicist known for the Hopfield network, a model of associative memory. MacKay's thesis, completed around 1991, applied Bayesian methods to neural networks and other adaptive models. It showed how probability could be used to set the complexity of a network and to compare different models, ideas that recur in this book.
He returned to Cambridge, where he worked in the Cavendish Laboratory, the university's physics department, and led a research group on inference. His research ranged widely: Bayesian neural networks, Gaussian processes, Monte Carlo methods, error-correcting codes and the design of interfaces. With Radford Neal, he showed in the mid 1990s that low-density parity-check codes, invented by Robert Gallager in the early 1960s and then largely forgotten, could perform close to the Shannon limit when decoded by message passing. This rediscovery helped transform the practice of coding and is one of the threads of the book.
He also helped develop Dasher, a text entry system that uses a probabilistic language model to let people write by steering a pointer through a moving field of letters. Dasher is a striking application of arithmetic coding turned into an interface: the user, in effect, acts as the decoder of a compressed stream. It was designed partly with people with disabilities in mind, and it reflects MacKay's interest in using information theory for practical good.
Energy and public life
In 2008 MacKay published Sustainable Energy, Without the Hot Air, a book that applied careful arithmetic to Britain's energy use and the possible sources of low carbon energy. Like this textbook, he made it free to read online. It was widely praised for replacing slogans with numbers. In 2009 he was appointed chief scientific adviser to the UK Department of Energy and Climate Change, a post he held for five years. He was elected a Fellow of the Royal Society and later became Regius Professor of Engineering at Cambridge.
MacKay died in 2016, at the age of forty-eight, after an illness with cancer. He was knighted shortly before his death. Colleagues remembered him for his clarity, his generosity with knowledge and his insistence on getting numbers right. The free availability of his books is part of that legacy. This textbook shows the same habits as his energy book: start from first principles, compute honestly, and explain in a way a careful student can follow.
The book also has an unusual relationship with its readers because of how it was released. MacKay posted drafts online for years before publication and invited corrections, and he kept the final text free to read after it appeared in print. Many students first met it as a file on a screen and only later bought the printed copy. This openness fitted the book's subject. A work about information, written by someone who believed knowledge should flow freely, was itself shared with as little friction as possible. Its many readers improved it through their corrections, and the printed text benefited from that long period of open review before and after publication.
The shape of the argument
The book opens with a problem rather than a definition. It asks how to communicate reliably over a channel that sometimes flips bits, and it works through simple codes, such as repeating each bit several times, to show both what can be done and the price paid. This opening introduces probability, inference and coding together, and it sets up the central surprise of information theory: that reliable communication does not require the rate of transmission to fall toward zero.
The first main part then treats data compression. It defines entropy, develops the idea that most long sequences from a source fall into a small typical set, and proves the limit on lossless compression. It then builds practical compression methods, from symbol codes to arithmetic coding and dictionary methods, and shows how each depends on a model of the data.
The second main part treats noisy channels. It defines mutual information and capacity, and works toward Shannon's noisy-channel coding theorem, explaining the proof through typical sets and random codes. A further part covers additional topics in information theory, including hashing, binary codes and their distances, and a well-known chapter on information acquisition in evolution, which asks how fast natural selection can add information to a genome and why sexual reproduction might help.
The largest part treats probabilities and inference. It sets out the Bayesian view, discusses model comparison and Occam's razor, and then develops a toolkit of methods: exact inference by message passing on graphs, clustering, maximum likelihood, the Laplace approximation, Monte Carlo methods of several kinds, variational methods and others. A part on neural networks presents single neurons as learners, Hopfield networks as memories, Boltzmann machines, supervised learning in multilayer networks and Gaussian processes. The final part, on sparse graph codes, brings the threads together: modern codes are defined by sparse graphs and decoded by the same message passing used for inference.
MacKay offers a map of the book with suggested routes through it for courses of different kinds: a short course on information theory, a course on Bayesian inference and machine learning, a course on coding and so on. This modular design is deliberate. The book is a web of related chapters rather than a single line, and readers are encouraged to choose a route that suits their aim.
Information can be measured
Surprise as a quantity
The first key idea is that information has a precise measure. When an event with probability p occurs, we can measure how surprising it is by the logarithm of one over p. With logarithms in base two, the unit is the bit. A fair coin toss carries one bit, since each outcome has probability one half. An event with probability one in a thousand carries about ten bits. A certain event carries none. This quantity, sometimes called the Shannon information content, has the property that information from independent events adds up.
The entropy of a source is the average information content of its outcomes. A fair coin has entropy of one bit per toss. A biased coin that lands heads ninety per cent of the time has entropy of less than half a bit, because most outcomes are unsurprising. Entropy is greatest when all outcomes are equally likely and zero when one outcome is certain. It measures our uncertainty about the source before we see the outcome.
A game of questions
MacKay makes the idea concrete through games of guessing. Think of identifying an unknown object by yes or no questions. A good questioner chooses each question so that the answer is equally likely to be yes or no, gaining one full bit per question. A poor questioner asks questions whose answers are predictable and learns little from each. The entropy of the unknown sets the minimum average number of good questions needed. This turns an abstract formula into a strategy anyone can practise, and it is a reminder that the most useful question is the one whose answer you cannot predict.
Why it matters
The measure matters because it turns vague notions such as amount of information into something one can compute, compare and optimise. It also has a meaning that is easy to forget: information is relative to a model. The same message is more or less surprising depending on what the receiver expected. Entropy is not a property of a message by itself but of a message together with the probability distribution it is drawn from. This point becomes the bridge from information theory to learning, since building a good model of a source and measuring its information are two sides of one task.
The idea is often confused with meaning or value. Shannon's measure says nothing about whether a message is important or true. A random string has high entropy and no meaning. MacKay is clear about this limit while showing how far the measure reaches nevertheless. Related quantities follow: joint entropy, conditional entropy, mutual information and relative entropy, the last of which measures how badly one probability distribution approximates another and returns later in the treatment of approximate inference.
Compression needs a model
The limit
The second key idea is that lossless compression has a firm limit set by entropy, and that reaching it depends entirely on how well we can predict the data. Shannon's source coding theorem says, roughly, that a long sequence from a source cannot be compressed to fewer bits than its entropy on average without losing information, and that it can be compressed to close to that amount. MacKay proves this through the idea of the typical set. For long sequences, almost all the probability is carried by a relatively small set of sequences whose information content is close to the length times the entropy. A code need only give short names to those.
An image helps. Toss a biased coin a thousand times. The particular sequence of all heads is the single most likely sequence, but it is very unlikely overall. Nearly every sequence you will actually see has about the expected proportion of heads, and the number of such sequences, though huge, is much smaller than the number of all possible sequences. Numbering only those typical sequences takes far fewer than a thousand bits.
From theory to practice
The book then builds working compression. Symbol codes assign a binary codeword to each symbol, with short codewords for common symbols. Huffman's algorithm finds the best such code for known probabilities. But symbol codes waste up to a bit per symbol and handle changing probabilities awkwardly. Arithmetic coding, which MacKay treats as the main practical tool, represents a whole message as a single number in an interval, narrowing the interval at each symbol in proportion to its predicted probability. Its output length comes within a small amount of the ideal for any probabilistic model, and the model can change from symbol to symbol.
This separates compression into two parts: modelling and coding. Coding is solved by arithmetic coding. Everything else depends on the model. A compressor that predicts the next letter of English well will compress English well. MacKay also discusses dictionary methods such as those of Lempel and Ziv, which compress without an explicit model, and explains how they implicitly learn one.
Where it leads
The link between prediction and compression is one of the book's most important lessons and has grown more relevant with time. Any system that predicts well can be turned into a compressor, and any good compressor contains a predictor. Large language models trained to predict the next word are, in this precise sense, compressors of text. The idea is sometimes stated loosely as compression equals understanding. MacKay's version is more exact and more modest: better prediction means shorter code, and the length of the code is a fair test of a model.
Reliable communication over noise
The surprise of the channel theorem
The third key idea is Shannon's noisy-channel coding theorem, which MacKay calls one of the most surprising results in science. Suppose we send bits through a channel that flips each bit with some probability, say one in ten. A naive approach to reliability is repetition: send each bit three times and take a majority vote. This lowers errors, but at a cost: we now send three times as many bits. To reduce errors further we must repeat more, and the rate of useful information falls toward zero. It seems natural to think that perfect reliability requires infinite repetition.
Shannon proved otherwise. Every channel has a capacity, a rate measured in bits per use. At any rate below capacity, there exist codes that make the probability of error as small as we like, provided we encode long enough blocks of data. Above capacity, reliable communication is impossible. For a channel that flips one bit in ten, the capacity is a little over half a bit per use. So we can, in principle, send about one useful bit for every two transmitted, with errors as rare as we wish.
How the proof works
MacKay explains the proof by typical sets and random coding. Choose codewords at random. When a codeword is sent, the received sequence lies, with high probability, in a cloud of typical outputs around it. If the codewords are few enough that their clouds rarely overlap, the receiver can identify which was sent. Capacity is the rate at which the clouds just fill the space of possible outputs. The striking feature of the proof is that random codes are good on average, so good codes must exist, yet the proof does not say how to find one that can be decoded efficiently.
Closing the gap
For decades after Shannon, practical codes fell well short of capacity. MacKay's own research, and the final part of the book, show how this gap was closed in the 1990s by turbo codes and low-density parity-check codes, both decoded by iterative message passing. The book treats the theorem not as an abstract curiosity but as a target that engineers eventually reached. Mobile phones, satellite links, storage devices and wireless networks now use codes of these kinds.
The idea is sometimes confused with a promise of error-free transmission at any rate. It is not. Capacity is a hard ceiling, and reaching close to it requires long blocks, which bring delay and computation. The theorem defines what is possible and what is not, and it changed how engineers think: noise does not force unreliability, it only sets a price in rate.
Codes in miniature
Adding the right redundancy
Before the full theory of channels, MacKay teaches through small codes, and the lesson they carry is worth stating on its own. Error correction works by adding redundancy, but redundancy of the right kind. Repetition adds redundancy crudely: every bit is copied, so the cost is high and the protection grows slowly. A block code adds a few check bits computed from a group of message bits, chosen so that any single error leaves a distinctive pattern. The receiver recomputes the checks, reads the pattern, and knows which bit to fix.
The classic small example is a Hamming code, which protects four message bits with three check bits and can correct any single flipped bit among the seven sent. MacKay shows it with a picture of overlapping circles, each enclosing a group of bits whose sum must be even. A single error breaks the parity of a particular combination of circles, and that combination points to the culprit. The picture makes a piece of algebra visible, and it already contains the seed of the sparse graph codes at the end of the book: bits linked to checks, and decoding as reasoning from broken checks back to probable errors.
Distance and its limits
The book introduces the idea of distance between codewords, the number of positions in which two codewords differ. A code whose codewords are far apart can tolerate more errors before one codeword is mistaken for another. Classical coding theory long focused on designing codes with large minimum distance. MacKay argues that this focus, while natural, can mislead. What matters for performance on a real noisy channel is the probability of decoding error, and a code can have a modest minimum distance and still perform superbly if bad error patterns are very rare. This shift from worst case to typical case is one of the book's characteristic moves, and it echoes the typical set argument behind compression.
Related chapters discuss hash codes, which give each item a short label for fast lookup, and the use of random codes in theory. Together these sections build an intuition for what a code is: a careful choice of which messages to allow, so that the allowed ones remain distinguishable after noise has done its work.
Inference as probability
The Bayesian stance
The fourth key idea is that reasoning under uncertainty should follow the rules of probability, applied to beliefs as well as to frequencies. This is the Bayesian view, and MacKay holds it firmly. A hypothesis, a parameter, or the identity of a sent message is something we are uncertain about, and our uncertainty can be described by a probability distribution. When data arrive, Bayes' theorem tells us how to update: the new belief in a hypothesis is proportional to the old belief times the probability the hypothesis gave to the observed data.
MacKay argues that this is not one method among many but the consistent way to reason, and that many alternatives either reduce to it or give odd answers in some cases. He criticises certain habits of classical statistics, such as some uses of significance tests and confidence intervals, and shows examples where they lead to conclusions a careful reasoner would reject. These sections are lively and partisan. A reader need not accept every criticism to benefit from seeing the issues stated sharply.
Inference everywhere
A virtue of the Bayesian view in this book is that it applies everywhere with the same rules. Decoding a noisy message is inference: given the received signal, what was probably sent? Fitting a model is inference: given the data, what parameter values are probable? Choosing between models is inference too. MacKay shows these problems side by side so that a reader sees a single pattern: write down a probabilistic model of how the data arose, condition on what was observed, and compute or approximate the resulting distribution.
The approach is often misread as a matter of choosing priors arbitrarily. MacKay addresses this directly. Priors express assumptions that every method makes in some form, and stating them openly makes them open to criticism. In many problems the data overwhelm the prior, and where they do not, the sensitivity of the answer to the prior is itself useful information. The real difficulty is not philosophical but computational: posterior distributions are often hard to compute, and the rest of this part of the book is largely about how to approximate them.
Occam's razor from probability
Why simpler models win
The fifth key idea is one of MacKay's most admired explanations: that Bayesian model comparison contains a built-in preference for simplicity. Occam's razor is the principle that we should not multiply assumptions beyond necessity. It is usually treated as a separate rule of taste, added on top of reasoning. MacKay shows that it falls out of probability theory without being assumed.
The argument runs as follows. A model is a family of possible explanations, and before seeing data, it spreads its probability across all the data sets it could produce. A simple model can produce only a few kinds of data, so it puts high probability on each. A complex model can produce many kinds, so it puts lower probability on each. When the data arrive, if they fall within what the simple model predicts, the simple model gave them higher probability and wins. The complex model is penalised not by a separate rule but because it spread its bets too widely. The quantity that measures this is the evidence, or marginal likelihood, of the model.
An analogy
Think of two forecasters. One predicts that tomorrow's temperature will be between twenty and twenty-two degrees. The other predicts it will be between zero and forty. If the temperature turns out to be twenty-one, both were right, but the first deserves more credit, because the first risked more. Bayesian evidence gives credit in exactly this way. The flexible model is not wrong; it is simply less informative, and the data reward the model that predicted them most sharply.
Where it leads
MacKay shows how to approximate the evidence using the Laplace approximation, which treats the posterior as a bell shape around its peak. The evidence then splits into two factors: how well the best-fitting parameters explain the data, and an Occam factor measuring how much the parameter space had to shrink to fit them. This framework, which MacKay developed in his thesis for neural networks, lets one set regularisation strengths and compare architectures without held-out data. It is a different route to the same goal that cross-validation pursues, and comparing the two is instructive. The link to compression is direct: a model with high evidence is one that would have encoded the data in few bits, which is the basis of the minimum description length principle.
Message passing on graphs
Local computation, global answers
The sixth key idea is that many inference problems can be solved by passing simple messages between neighbours in a graph. MacKay introduces the idea with a homely example of counting: soldiers in a line can find their total number without anyone seeing the whole line, if each tells the next how many are behind him. The same principle, applied to probabilities, allows the computation of marginal distributions in large models by local operations.
When a probabilistic model can be drawn as a graph without loops, such as a chain or a tree, the sum-product algorithm computes exact marginals efficiently. Each node sends to each neighbour a summary of everything it has learned from the rest of the graph. In a chain, this is the forward and backward algorithm used for hidden Markov models in speech recognition. A closely related algorithm, using maxima instead of sums, finds the single most probable configuration, as the Viterbi algorithm does for decoding convolutional codes.
Loops and approximation
Many important graphs have loops, and on them message passing is not exact. Yet running it anyway, a practice called loopy belief propagation, often gives excellent approximate answers. The decoding of turbo codes and low-density parity-check codes is exactly this: message passing on a graph with many long loops, which turns out to work extraordinarily well. Understanding when and why loopy propagation works has been an active research question, and the book presents it honestly as a method justified by its performance more than by complete theory.
The idea is easily confused with a particular algorithm. It is better seen as a way of thinking. A large problem with local structure can be broken into small exchanges, each easy to compute. The same idea appears in Pearl's work on Bayesian networks, in statistical physics, in coding and in modern graph neural networks. MacKay's book is one of the clearest places to see these uses as one.
Clustering, likelihood and hidden causes
A simple learner examined closely
A further idea, developed in the inference part, is that even the simplest learning algorithms can be understood as approximate inference, and that seeing them this way exposes their weaknesses and suggests repairs. MacKay's example is K-means clustering, a familiar method that assigns each data point to the nearest of K centres and then moves each centre to the average of its points, repeating until nothing changes. It is fast and easy, and it is often used without thought.
MacKay shows its flaws plainly. It makes hard assignments, so a point halfway between two centres is forced wholly into one. It assumes clusters are round and of similar size, so it splits a long cluster or merges a small one into a large neighbour. And it offers no principled way to choose the number of clusters. He then replaces it with a soft version, in which each point is shared among clusters according to how probable it is that each produced it. This soft version is an instance of fitting a mixture model by maximum likelihood, and the alternating steps of assigning and updating become the expectation maximisation algorithm.
The trouble with maximum likelihood
MacKay then shows that maximum likelihood itself has a pathology in this setting. A cluster can shrink onto a single data point, its width going to zero and its likelihood to infinity. The best-fitting model by the likelihood criterion is therefore absurd. The Bayesian remedy is to place a prior on cluster widths and to average over parameters rather than pick the single best. This small example carries a large lesson: methods that choose single best values can fail in ways that methods which keep track of uncertainty avoid.
The idea of hidden causes runs under this whole discussion. Each data point is assumed to come from one of several unseen sources, and inference is the work of reasoning back from observed points to the sources that produced them. This is the same structure as decoding a message, and the same structure as many later models in machine learning, from topic models of text to models of speech. A reader who grasps it in the case of clustering will recognise it everywhere.
The idea is often confused with a claim that simple methods are useless. MacKay's point is the opposite. Simple methods are valuable, but they should be understood as approximations to a fuller probabilistic model, so that one knows when the approximation will fail and how to improve it.
Sampling when exact answers fail
Why sample
The seventh key idea is that when exact inference is impossible, we can often draw random samples from a distribution and use them to estimate whatever we need. A posterior distribution over many parameters may be impossible to compute in closed form, but if we can generate samples from it, averages over the samples approximate the quantities we care about. This is the Monte Carlo method, named after the casino, and MacKay gives it extended and practical treatment.
He starts with simple methods and shows why they fail in high dimensions. Importance sampling draws from an easy distribution and reweights, but the weights become wildly uneven when the easy distribution differs much from the target. Rejection sampling proposes points and rejects most of them, but in many dimensions it rejects nearly all. These failures motivate methods that move through the space step by step.
Markov chain methods
The Metropolis method proposes a small move from the current point and accepts or rejects it according to a simple rule that guarantees, in the long run, samples from the target distribution. Gibbs sampling updates one variable at a time from its conditional distribution. MacKay stresses the practical problems: chains can move slowly, samples can be strongly correlated, and it can be hard to tell whether a chain has explored the whole space. He devotes attention to methods that move more efficiently, including slice sampling, which adapts its step size automatically, and Hamiltonian Monte Carlo, which borrows ideas from physics to make long moves guided by the shape of the distribution. He also covers exact sampling methods that can certify when a chain has forgotten its starting point.
An image
A useful picture is a walker exploring a dark mountain range, trying to spend time in each region in proportion to its height. The walker cannot see the whole range, only feel the ground nearby. Random small steps explore slowly. Steps guided by the slope and the walker's momentum explore faster. The walker's path, recorded over a long time, becomes a map of where the high ground lies. Monte Carlo methods turn this image into algorithms, and MacKay's discussion of the walker's practical troubles is among the most useful sections in the book.
Hamiltonian Monte Carlo, which MacKay presents carefully, later became the engine of widely used probabilistic programming tools. The idea is often confused with mere random guessing. It is controlled randomness with guarantees, and the art lies in designing moves that explore efficiently.
Approximation by optimisation
Variational methods
The eighth key idea offers an alternative to sampling. Instead of drawing samples from a difficult distribution, we can search a family of simpler distributions for the one closest to it. Closeness is measured by relative entropy, the information-theoretic quantity introduced early in the book. This turns inference into optimisation. The method is called variational, and in physics it has long been used under the name of mean field theory.
MacKay presents variational free energy minimisation, showing that the quantity being minimised has a direct interpretation: it is an upper bound on a quantity related to the evidence, and minimising it makes the bound as tight as possible. The simplest version assumes the approximating distribution treats variables as independent, which makes computation easy but ignores correlations. He applies the method to examples including the Ising model of magnetism, showing how ideas from statistical physics enter inference.
Choosing between sampling and optimisation
Monte Carlo methods are, in principle, exact given enough time, but they can be slow and hard to diagnose. Variational methods are fast and give a definite answer, but that answer is biased by the choice of approximating family. MacKay discusses the trade-off and the direction of the bias: the usual variational approximation tends to be too narrow, underestimating uncertainty. This understanding is valuable in practice, since modern machine learning uses variational methods heavily, for example in variational autoencoders, and their tendency to overconfidence matters.
The book also covers other approximations, such as the Laplace approximation and expectation propagation in brief. The overall lesson is that there is no single best method of approximate inference. Each trades accuracy, speed and ease of use differently, and a good practitioner chooses with an understanding of what each gives up. The common thread is that all are judged by how well they approximate the true posterior, a standard that the earlier chapters on information make precise.
Neurons and networks as learners
A neuron as a classifier
The ninth key idea is that neural networks are best understood as probabilistic models, subject to the same principles of inference as everything else. MacKay begins with a single neuron, treating it as a classifier that takes inputs, forms a weighted sum and passes it through an S-shaped function to produce a probability. Learning the weights is then a problem of inference. He shows how overfitting arises, how adding a penalty on weight size corresponds to a prior, and how the Bayesian approach gives not only predictions but measures of how confident those predictions should be.
He also asks how much a single neuron can learn, measured in bits. This gives an information-theoretic view of capacity: a neuron with a certain number of inputs can store roughly a predictable number of arbitrary labels. The same style of question appears for Hopfield networks, which store memories as stable patterns of activity and can recover a stored pattern from a corrupted version. MacKay discusses their capacity and failure modes, linking memory to error correction.
Boltzmann machines and Gaussian processes
Boltzmann machines are networks whose states follow a probability distribution borrowed from statistical physics, and whose learning rule has an elegant form that compares statistics of the network driven by data with statistics of the network running freely. MacKay shows how this rule follows from maximising likelihood. He then treats multilayer networks for supervised learning, and finally Gaussian processes, which can be seen as the limit of a network with infinitely many hidden units and which allow exact Bayesian prediction for regression problems.
Read today, this part of the book is a valuable corrective. Modern deep learning often treats networks as engineering systems to be tuned rather than as models to be reasoned about. MacKay's view, that a network is a probabilistic model and that its uncertainty matters, has returned in work on Bayesian deep learning and calibration. The connection between networks and Gaussian processes, which he presents, has also been extended to very wide modern networks.
Sparse graph codes
Codes made of graphs
The tenth key idea brings the book's halves together. Low-density parity-check codes are defined by a sparse bipartite graph connecting transmitted bits to parity checks, each check requiring that a small group of bits add up to an even number. Because each check involves few bits and each bit few checks, the graph is sparse. Decoding means inferring the transmitted bits from noisy received values, subject to the checks. This is exactly an inference problem on a graph, and message passing solves it: bits and checks exchange beliefs repeatedly until the beliefs settle.
MacKay shows how such codes, with long block lengths, perform remarkably close to the Shannon limit. He also discusses turbo codes, repeat-accumulate codes and digital fountain codes. Fountain codes solve a different problem: sending a file to many receivers over a channel that loses packets. The sender produces an endless stream of encoded packets, each a combination of a few original pieces, and any receiver who collects slightly more packets than the original file contains can reconstruct it, regardless of which packets were lost. MacKay explains the design of such codes clearly and shows why they work.
Why this ending matters
The final part is the payoff for the reader who has worked through the rest. Information theory set the limit. Inference provided the decoding principle. Message passing provided the algorithm. Together they produced codes that reached the limit Shannon had proved existed fifty years earlier. MacKay's own research was part of this story, and he tells it with evident pleasure. The lesson for the reader is that the unity claimed in the book's title is not a slogan. It led to working technology that most people use every day without knowing it.
A detour through evolution
Information and natural selection
One chapter has become well known beyond the book's usual readers. In it MacKay asks how quickly natural selection can add information to a species' genome, and what difference sexual reproduction makes. He uses simple models of populations whose fitness depends on many genes, and he measures the rate of gain in bits per generation. The result, in his models, is that sexual reproduction allows information to accumulate much faster than asexual reproduction, roughly in proportion to the square root of the genome size, and allows a species to tolerate a higher mutation rate.
The chapter is offered as a model and an exercise in thinking, not as a final word on biology, and biologists have long debated why sex evolved. Its value here is to show that information theory applies wherever one asks how much is learned, how fast, under what noise. A population under selection is, in a sense, a learner receiving feedback from its environment through a noisy channel. Seeing evolution this way is a good test of whether a reader has absorbed the book's habit of looking for the information in a process.
A way of teaching
Learning by working
The book's method of teaching deserves a chapter of its own, because it is part of what the book has to offer. MacKay does not present finished results and then add exercises at the end of a chapter. He interrupts the text with problems and asks the reader to stop and try them before reading on. Often the next paragraph depends on the answer. The exercises are graded by difficulty and marked by importance, and many have worked solutions at the end of each chapter. The intention is that the reader builds the ideas rather than receives them.
This approach suits the subject. Many results in information theory and inference are surprising, and a surprise only teaches if one first held the expectation it overturns. By asking the reader to guess before revealing the answer, MacKay makes sure the expectation is there. A reader who guesses that reliable communication needs endless repetition, and then sees that it does not, remembers the channel coding theorem far better than one who reads the statement cold.
Puzzles and pictures
MacKay also uses puzzles drawn from everyday life: weighing balls to find an odd one, guessing games, simple betting problems and questions about tests for disease. These are chosen because they hold the essential structure of a deeper result while being small enough to work by hand. The weighing problem, for example, teaches that the best experiment is one whose outcomes are as equally likely as possible, which is the same principle as the game of questions and the same quantity as entropy. The book is generous with diagrams, many drawn to show a computation unfolding rather than a finished result.
Finally, MacKay is honest about computation. He tells the reader which methods are practical, which are slow, which fail silently, and how to check. This candour is rare in textbooks, which often present methods at their best. It reflects his background as a working researcher who built codes and samplers and saw them break. A reader learns not only how methods are meant to work but how to recognise when they are not working, which is the more valuable skill.
The style is part of why the book is loved. It treats the reader as a capable partner, expects effort, and rewards it with understanding that lasts. Readers who only skim it miss most of what it offers.
The tradition around it
What came before
The book stands on Claude Shannon's 1948 paper on the mathematical theory of communication, which founded information theory, and on the work that followed on coding theory, including Richard Hamming's error-correcting codes, Robert Gallager's low-density parity-check codes and the textbooks of Thomas Cover and Joy Thomas. On the inference side, it draws on the Bayesian tradition from Thomas Bayes and Pierre-Simon Laplace, revived in the twentieth century by Harold Jeffreys, Edwin Jaynes and others. Jaynes's view of probability as extended logic is especially close to MacKay's. From physics come statistical mechanics, the Ising model and Monte Carlo methods, and from the study of neural networks the work of Hopfield and others.
Several textbooks covered parts of this ground before 2003, but few, if any, combined them as MacKay did. Most information theory books said little about learning; most machine learning books said little about coding. MacKay's choice to unite them reflected his own research path, which moved between physics, neural networks and codes.
What came after
In the years since, the unity MacKay argued for has become more visible. Variational methods and message passing became central to machine learning. Hamiltonian Monte Carlo became the standard sampler in probabilistic programming. The link between prediction and compression became a common way to think about large language models. Low-density parity-check codes were adopted in wireless and storage standards. The book did not cause all of this, but it trained many of the people who did the work and gave them a common view.
Its neighbours on this shelf
Probabilistic Reasoning in Intelligent Systems by Judea Pearl introduced belief propagation on graphs, which MacKay develops and applies to codes. Pattern Recognition and Machine Learning by Christopher Bishop shares MacKay's Bayesian outlook and covers graphical models, variational methods and sampling with a focus on machine learning; Bishop's book reads as a natural companion and is somewhat more systematic. The Elements of Statistical Learning gives the frequentist counterpart, judging methods by validation rather than by evidence. Causality by Pearl marks a boundary: MacKay's methods infer what is probable given observations, while Pearl asks what happens under intervention.
Godel, Escher, Bach by Douglas Hofstadter shares MacKay's playfulness and love of puzzles, though its subject is self-reference rather than probability. Parallel Distributed Processing and Perceptrons provide the history of the neural network ideas MacKay treats probabilistically. On Intelligence by Jeff Hawkins presents the brain as a prediction machine, a view that MacKay's link between prediction and compression helps make precise.
Questions and criticisms
Fair objections
The book's Bayesian stance is strong, and readers trained in classical statistics may find its criticisms of significance testing and confidence intervals one-sided. MacKay's examples are well chosen, but classical methods have defenders who would argue that they answer different questions, such as long-run error rates of procedures, and that Bayesian methods carry their own dangers when priors are poorly chosen. A reader should treat these sections as argument, not settled fact, while recognising that much of modern machine learning has moved toward the probabilistic view MacKay favoured.
The book is also uneven by design. Its modular structure means that some chapters are short sketches and others long developments, and the routes through it require planning. Some readers find the frequent exercises in the text distracting, and some solutions are brief. The breadth that makes the book distinctive also means that no single topic is treated with the completeness of a specialist text.
Some readers also note that the book assumes the reader will do the work. Without the exercises much of its value is lost, and a reader short of time may come away with fragments. That is less a flaw than a demand, but it is worth knowing before starting. A slower reading, with the pencil always out, repays the time many times over.
What has aged
The chapters on neural networks predate deep learning. They do not cover convolutional networks, recurrent networks, modern optimisation or the training of very large models. Some coding discussion predates later developments such as polar codes, which also approach capacity. Software and computation have changed greatly, and a modern reader will use tools that did not exist in 2003.
What has held up
Much has held up remarkably well. The treatment of entropy, compression and the channel coding theorem is timeless in the way good mathematics is. The account of Bayesian model comparison and the Occam factor remains one of the clearest available. The discussion of Monte Carlo methods, especially of their practical pitfalls, is still recommended to students. The unifying vision, that compression, communication and learning are one subject, now looks less like an eccentric choice and more like foresight. Above all, the habit the book teaches, of writing down a probabilistic model and reasoning from it honestly, has not aged at all.
Why it is on this shelf
This book sits in the artificial intelligence bay because it explains, from the ground up, why learning systems work as they do. A system that predicts the next word, recognises speech or corrects errors in a signal is, in each case, doing inference under uncertainty, and the limits on what it can achieve are information-theoretic. Few books make these connections as directly as this one, and none we know of makes them with as much clarity and good humour.
For a reader of science, it offers a single language for measurement, evidence and noise. The entropy of a source, the capacity of a channel and the evidence for a model are tools that apply in physics, biology and engineering alike. For a reader of economics, the ideas of information as reduction of uncertainty and of the value of a well-chosen question are directly useful. Markets, surveys and experiments are channels through which noisy information passes, and the book's discipline helps in judging how much any of them can reveal.
For a reader of technology, the book is a foundation for understanding compression, communication, storage and modern machine learning together. Much engineering knowledge is fragmented across specialities. This book shows the common root and so makes new developments easier to place.
For a reader of Vedanta and Jyotish, the book offers a precise account of a theme those traditions also treat: the relation between what is known, what is uncertain, and what can be inferred. Its central teaching, that information is always relative to a model held by the receiver, has a philosophical depth that goes beyond engineering. It also gives a disciplined way to ask how much a sign, an omen or a chart could in principle tell us, given the noise in the channel. We keep it here as a teacher of careful reasoning about evidence, written by someone who cared about getting the numbers right.
How to read it
Choose a route
Begin by studying MacKay's own map of the book and his suggested courses. Decide what you want first: the theory of information and coding, the methods of Bayesian inference and machine learning, or a broad tour. Each route uses a different subset of chapters. Trying to read the book straight through from first page to last is possible but slow, and MacKay himself discourages it.
First pass
For most readers, start with the opening chapter on the noisy channel, and work every exercise it sets. It is the best introduction in the book and shows its method. Then read the chapters on probability, entropy and inference, and those on data compression up to and including arithmetic coding. At this point you will understand the first half of the book's unity: that compression is modelling.
Then switch to the inference part. Read the chapters on Bayesian inference and model comparison, including the discussion of Occam's razor, and the chapter on exact inference by message passing. Then read the chapters on Monte Carlo methods. At a pace of one chapter every two or three days, with exercises, this first pass takes two to three months.
What to skip at first
On a first pass, skim the chapters on further topics in information theory, the more specialised coding chapters, the chapters on Ising models and the more advanced Monte Carlo methods. The neural network chapters can be read quickly for their framing. Save the sparse graph codes part for the end of the second pass, when it will feel like a reward rather than a burden.
Second pass with a pencil
On a second pass, work through the noisy-channel coding theorem with care, drawing the picture of typical sets and decoding clouds. Implement arithmetic coding for a simple model and watch the output length approach the entropy. Implement the Metropolis method and slice sampling for a small posterior and observe how they explore. Implement a small low-density parity-check decoder. These exercises are not decoration; the book is designed so that understanding comes from doing them.
Keeping a working notebook
Keep a notebook for the book's exercises, and write each answer before checking the solution. Record not only right answers but wrong guesses, especially where your intuition failed, since those are the places where the book is teaching you most. Return to the notebook after a month and redo a few key exercises without looking: the weighing puzzle, the capacity of a simple channel, the evidence for two competing models, a short run of a sampler. If they come back easily, the ideas have settled. If not, reread the surrounding chapter before moving on.
Readers who prefer to learn by building can turn the book into a set of small programs: a compressor driven by a simple adaptive model, a decoder for a small code, a sampler and a variational approximation for the same toy problem. Comparing their outputs side by side shows the book's unity in a way no reading can. Many of the most memorable lessons come from watching a method that should work fail, then finding the reason in the text.
What next from this shelf
Read Pattern Recognition and Machine Learning by Bishop for a more systematic treatment of the same probabilistic methods applied to machine learning. Read Probabilistic Reasoning in Intelligent Systems by Pearl for the origins of belief propagation. Read The Elements of Statistical Learning for the contrasting frequentist view, and Causality by Pearl to see what probability alone cannot answer.
Questions to carry
- What model of the source is implied by the way you currently compress or summarise your data?
- How much information, in bits, could a given experiment or question give you at most?
- Which of your beliefs would change most if you learned one more bit of the right kind?
- Why does good prediction imply good compression, and does the converse hold in your field?
- At what rate can information pass through the noisy channels you rely on, and are you trying to exceed it?
- When you prefer a simpler explanation, can you say in probabilistic terms why it should win?
- Which of your models spread their predictions so widely that no outcome could surprise them?
- When exact inference is impossible, would you rather sample or approximate, and what would each cost you?
- In what direction is your approximation likely to be biased, and does that bias make you overconfident?
- Where in your work is a large problem made of many local constraints that could be solved by passing messages?
- How would you explain the channel coding theorem to someone who believes reliability requires endless repetition?
- What does it mean that information is relative to the receiver's model?
- In what sense is a learning system a channel between the world and its predictions?
Words to know
- Bit: the unit of information, equal to the outcome of a fair binary choice.
- Shannon information content: the logarithm of one over the probability of an outcome, measuring its surprise.
- Entropy: the average information content of a source, measuring uncertainty before an outcome is known.
- Typical set: the relatively small set of long sequences that carries almost all the probability of a source.
- Source coding theorem: the result that data cannot be losslessly compressed below their entropy on average, and can nearly reach it.
- Symbol code: a code that assigns a codeword to each individual symbol, as in Huffman coding.
- Arithmetic coding: compression that represents a whole message as an interval narrowed by predicted probabilities.
- Mutual information: the amount of information one variable gives about another.
- Relative entropy: a measure of how badly one probability distribution approximates another; also called Kullback Leibler divergence.
- Channel capacity: the highest rate at which information can be sent reliably over a noisy channel.
- Noisy-channel coding theorem: Shannon's result that reliable communication is possible at any rate below capacity.
- Bayes' theorem: the rule for updating beliefs, multiplying prior belief by the probability of the data.
- Evidence: the probability a model assigns to the observed data, averaged over its parameters; used to compare models.
- Occam factor: the part of the evidence that penalises a model for spreading its predictions over many possibilities.
- Laplace approximation: approximating a distribution by a bell shape around its peak.
- Message passing: computing global quantities in a graph by exchanging local summaries between neighbours.
- Sum-product algorithm: a message passing method that computes marginal probabilities on graphs.
- Monte Carlo method: estimating quantities by averaging over random samples.
- Metropolis method: a Markov chain method that proposes moves and accepts them by a rule ensuring correct long-run sampling.
- Hamiltonian Monte Carlo: a sampling method that uses simulated momentum to make long, guided moves.
- Variational method: approximating a difficult distribution by the closest member of a simpler family.
- Gaussian process: a probability distribution over functions, used for flexible Bayesian regression.
- Low-density parity-check code: an error-correcting code defined by a sparse graph and decoded by message passing.
- Fountain code: a code that produces an endless stream of packets, any sufficient number of which recover the original file.
A note on this edition
This is a study edition written for this shelf in our own words. It describes the ideas and context of David MacKay's Information Theory, Inference, and Learning Algorithms but does not reproduce its text, figures or exercises. The book itself is in copyright. MacKay chose to make it free to read online, and it is also well worth owning in print from a bookshop or borrowing from a library, so that its exercises can be worked with a pencil at hand.