




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
©^ c1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 ©cCambridge University Press 2003
Version 7.2 (fourth printing) March 28, 2005
Please send feedback on this book via http://www.inference.phy.cam.ac.uk/mackay/itila/
Version 6.0 of this book was published by C.U.P. in September 2003. It will remain viewable on-screen on the above website, in postscript, djvu, and pdf formats.
In the second printing (version 6.6) minor typos were corrected, and the book design was slightly altered to modify the placement of section numbers.
In the third printing (version 7.0) minor typos were corrected, and chapter 8 was renamed ‘Dependent random variables’ (instead of ‘Correlated’).
In the fourth printing (version 7.2) minor typos were corrected.
(C.U.P. replace this page with their own page ii.)
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
Preface
This book is aimed at senior undergraduates and graduate students in Engi- neering, Science, Mathematics, and Computing. It expects familiarity with calculus, probability theory, and linear algebra as taught in a first- or second- year undergraduate course on mathematics for scientists and engineers. Conventional courses on information theory cover not only the beauti- ful theoretical ideas of Shannon, but also practical solutions to communica- tion problems. This book goes further, bringing in Bayesian data modelling, Monte Carlo methods, variational methods, clustering algorithms, and neural networks. Why unify information theory and machine learning? Because they are two sides of the same coin. In the 1960s, a single field, cybernetics, was populated by information theorists, computer scientists, and neuroscientists, all studying common problems. Information theory and machine learning still belong together. Brains are the ultimate compression and communication systems. And the state-of-the-art algorithms for both data compression and error-correcting codes use the same tools as machine learning.
The essential dependencies between chapters are indicated in the figure on the next page. An arrow from one chapter to another indicates that the second chapter requires some of the first. Within Parts I, II, IV, and V of this book, chapters on advanced or optional topics are towards the end. All chapters of Part III are optional on a first reading, except perhaps for Chapter 16 (Message Passing). The same system sometimes applies within a chapter: the final sections of- ten deal with advanced topics that can be skipped on a first reading. For exam- ple in two key chapters – Chapter 4 (The Source Coding Theorem) and Chap- ter 10 (The Noisy-Channel Coding Theorem) – the first-time reader should detour at section 4.5 and section 10.4 respectively. Pages vii–x show a few ways to use this book. First, I give the roadmap for a course that I teach in Cambridge: ‘Information theory, pattern recognition, and neural networks’. The book is also intended as a textbook for traditional courses in information theory. The second roadmap shows the chapters for an introductory information theory course and the third for a course aimed at an understanding of state-of-the-art error-correcting codes. The fourth roadmap shows how to use the text in a conventional course on machine learning.
v
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
Preface vii
1 Introduction to Information Theory
3 More about Inference
I Data Compression
4 The Source Coding Theorem 5 Symbol Codes 6 Stream Codes 7 Codes for Integers
II Noisy-Channel Coding
8 Dependent Random Variables 9 Communication over a Noisy Channel 10 The Noisy-Channel Coding Theorem 11 Error-Correcting Codes and Real Channels
III Further Topics in Information Theory
12 Hash Codes 13 Binary Codes 14 Very Good Linear Codes Exist 15 Further Exercises on Information Theory 16 Message Passing 17 Constrained Noiseless Channels 18 Crosswords and Codebreaking 19 Why have Sex?
IV Probabilities and Inference
20 An Example Inference Task: Clustering 21 Exact Inference by Complete Enumeration 22 Maximum Likelihood and Clustering 23 Useful Probability Distributions 24 Exact Marginalization 25 Exact Marginalization in Trellises 26 Exact Marginalization in Graphs 27 Laplace’s Method 28 Model Comparison and Occam’s Razor 29 Monte Carlo Methods 30 Efficient Monte Carlo Methods 31 Ising Models 32 Exact Monte Carlo Sampling 33 Variational Methods 34 Independent Component Analysis 35 Random Inference Topics 36 Decision Theory 37 Bayesian Inference and Sampling Theory
V Neural networks
38 Introduction to Neural Networks 39 The Single Neuron as a Classifier 40 Capacity of a Single Neuron 41 Learning as Inference 42 Hopfield Networks 43 Boltzmann Machines 44 Supervised Learning in Multilayer Networks 45 Gaussian Processes 46 Deconvolution
VI Sparse Graph Codes
47 Low-Density Parity-Check Codes 48 Convolutional Codes and Turbo Codes 49 Repeat–Accumulate Codes 50 Digital Fountain Codes
1 Introduction to Information Theory 2 Probability, Entropy, and Inference 3 More about Inference
4 The Source Coding Theorem 5 Symbol Codes 6 Stream Codes
8 Dependent Random Variables 9 Communication over a Noisy Channel 10 The Noisy-Channel Coding Theorem 11 Error-Correcting Codes and Real Channels
20 An Example Inference Task: Clustering 21 Exact Inference by Complete Enumeration 22 Maximum Likelihood and Clustering
24 Exact Marginalization
27 Laplace’s Method
29 Monte Carlo Methods 30 Efficient Monte Carlo Methods 31 Ising Models 32 Exact Monte Carlo Sampling 33 Variational Methods
38 Introduction to Neural Networks 39 The Single Neuron as a Classifier 40 Capacity of a Single Neuron 41 Learning as Inference 42 Hopfield Networks
47 Low-Density Parity-Check Codes
My Cambridge Course on, Information Theory, Pattern Recognition, and Neural Networks
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
viii Preface
1 Introduction to Information Theory 2 Probability, Entropy, and Inference 3 More about Inference
I Data Compression
4 The Source Coding Theorem 5 Symbol Codes 6 Stream Codes 7 Codes for Integers
II Noisy-Channel Coding
8 Dependent Random Variables 9 Communication over a Noisy Channel 10 The Noisy-Channel Coding Theorem 11 Error-Correcting Codes and Real Channels
III Further Topics in Information Theory
12 Hash Codes 13 Binary Codes 14 Very Good Linear Codes Exist 15 Further Exercises on Information Theory 16 Message Passing 17 Constrained Noiseless Channels 18 Crosswords and Codebreaking 19 Why have Sex?
IV Probabilities and Inference
20 An Example Inference Task: Clustering 21 Exact Inference by Complete Enumeration 22 Maximum Likelihood and Clustering 23 Useful Probability Distributions 24 Exact Marginalization 25 Exact Marginalization in Trellises 26 Exact Marginalization in Graphs 27 Laplace’s Method 28 Model Comparison and Occam’s Razor 29 Monte Carlo Methods 30 Efficient Monte Carlo Methods 31 Ising Models 32 Exact Monte Carlo Sampling 33 Variational Methods 34 Independent Component Analysis 35 Random Inference Topics 36 Decision Theory 37 Bayesian Inference and Sampling Theory
V Neural networks
38 Introduction to Neural Networks 39 The Single Neuron as a Classifier 40 Capacity of a Single Neuron 41 Learning as Inference 42 Hopfield Networks 43 Boltzmann Machines 44 Supervised Learning in Multilayer Networks 45 Gaussian Processes 46 Deconvolution
VI Sparse Graph Codes
47 Low-Density Parity-Check Codes 48 Convolutional Codes and Turbo Codes 49 Repeat–Accumulate Codes 50 Digital Fountain Codes
1 Introduction to Information Theory 2 Probability, Entropy, and Inference
4 The Source Coding Theorem 5 Symbol Codes 6 Stream Codes
8 Dependent Random Variables 9 Communication over a Noisy Channel 10 The Noisy-Channel Coding Theorem
Short Course on Information Theory
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
x Preface
1 Introduction to Information Theory 2 Probability, Entropy, and Inference 3 More about Inference
I Data Compression
4 The Source Coding Theorem 5 Symbol Codes 6 Stream Codes 7 Codes for Integers
II Noisy-Channel Coding
8 Dependent Random Variables 9 Communication over a Noisy Channel 10 The Noisy-Channel Coding Theorem 11 Error-Correcting Codes and Real Channels
III Further Topics in Information Theory
12 Hash Codes 13 Binary Codes 14 Very Good Linear Codes Exist 15 Further Exercises on Information Theory 16 Message Passing 17 Constrained Noiseless Channels 18 Crosswords and Codebreaking 19 Why have Sex?
IV Probabilities and Inference
20 An Example Inference Task: Clustering 21 Exact Inference by Complete Enumeration 22 Maximum Likelihood and Clustering 23 Useful Probability Distributions 24 Exact Marginalization 25 Exact Marginalization in Trellises 26 Exact Marginalization in Graphs 27 Laplace’s Method 28 Model Comparison and Occam’s Razor 29 Monte Carlo Methods 30 Efficient Monte Carlo Methods 31 Ising Models 32 Exact Monte Carlo Sampling 33 Variational Methods 34 Independent Component Analysis 35 Random Inference Topics 36 Decision Theory 37 Bayesian Inference and Sampling Theory
V Neural networks
38 Introduction to Neural Networks 39 The Single Neuron as a Classifier 40 Capacity of a Single Neuron 41 Learning as Inference 42 Hopfield Networks 43 Boltzmann Machines 44 Supervised Learning in Multilayer Networks 45 Gaussian Processes 46 Deconvolution
VI Sparse Graph Codes
47 Low-Density Parity-Check Codes 48 Convolutional Codes and Turbo Codes 49 Repeat–Accumulate Codes 50 Digital Fountain Codes
2 Probability, Entropy, and Inference 3 More about Inference
20 An Example Inference Task: Clustering 21 Exact Inference by Complete Enumeration 22 Maximum Likelihood and Clustering
24 Exact Marginalization
27 Laplace’s Method 28 Model Comparison and Occam’s Razor 29 Monte Carlo Methods 30 Efficient Monte Carlo Methods 31 Ising Models 32 Exact Monte Carlo Sampling 33 Variational Methods 34 Independent Component Analysis
38 Introduction to Neural Networks 39 The Single Neuron as a Classifier 40 Capacity of a Single Neuron 41 Learning as Inference 42 Hopfield Networks 43 Boltzmann Machines 44 Supervised Learning in Multilayer Networks 45 Gaussian Processes
A Course on Bayesian Inference and Machine Learning
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
Preface xi
You can understand a subject only by creating it for yourself. The exercises play an essential role in this book. For guidance, each has a rating (similar to that used by Knuth (1968)) from 1 to 5 to indicate its difficulty. In addition, exercises that are especially recommended are marked by a marginal encouraging rat. Some exercises that require the use of a computer are marked with a C. Answers to many exercises are provided. Use them wisely. Where a solu- tion is provided, this is indicated by including its page number alongside the difficulty rating. Solutions to many of the other exercises will be supplied to instructors using this book in their teaching; please email [email protected].
Summary of codes for exercises
Especially recommended
. Recommended C Parts require a computer [p. 42] Solution provided on page 42
[ 1 ] Simple (one minute) [ 2 ] Medium (quarter hour) [ 3 ] Moderately hard [ 4 ] Hard [ 5 ] Research project
The website
http://www.inference.phy.cam.ac.uk/mackay/itila
contains several resources:
This is the fourth printing of the first edition. In the second printing, the design of the book was altered slightly. Page-numbering generally remained unchanged, except in chapters 1, 6, and 28, where a few paragraphs, figures, and equations moved around. All equation, section, and exercise numbers were unchanged. In the third printing, chapter 8 was renamed ‘Dependent Random Variables’, instead of ‘Correlated’, which was sloppy.
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
About Chapter 1
In the first chapter, you will need to be familiar with the binomial distribution. And to solve the exercises in the text – which I urge you to do – you will need to know Stirling’s approximation for the factorial function, x! ' xx^ e−x, and be able to apply it to
r
= (^) (N −Nr^ !)! r!. These topics are reviewed below. Unfamiliar notation? See Appendix A, p.598.
Example 1.1. A bent coin has probability f of coming up heads. The coin is tossed N times. What is the probability distribution of the number of heads, r? What are the mean and variance of r?
0
0 1 2 3 4 5 6 7 8 9 10 r
Figure 1.1. The binomial distribution P (r | f = 0. 3 , N = 10).
Solution. The number of heads has a binomial distribution.
P (r | f, N ) =
r
f r(1 − f )N^ −r. (1.1)
The mean, E[r], and variance, var[r], of this distribution are defined by
E[r] ≡
r=
P (r | f, N ) r (1.2)
var[r] ≡ E
(r − E[r])^2
= E[r^2 ] − (E[r])^2 =
r=
P (r | f, N )r^2 − (E[r])^2. (1.4)
Rather than evaluating the sums over r in (1.2) and (1.4) directly, it is easiest to obtain the mean and variance by noting that r is the sum of N independent random variables, namely, the number of heads in the first toss (which is either zero or one), the number of heads in the second toss, and so forth. In general,
E[x + y] = E[x] + E[y] for any random variables x and y; var[x + y] = var[x] + var[y] if x and y are independent.
So the mean of r is the sum of the means of those random variables, and the variance of r is the sum of their variances. The mean number of heads in a single toss is f × 1 + (1 − f ) × 0 = f , and the variance of the number of heads in a single toss is [ f × 12 + (1 − f ) × 02
− f 2 = f − f 2 = f (1 − f ), (1.6)
so the mean and variance of r are:
E[r] = N f and var[r] = N f (1 − f ). 2 (1.7)
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
2 About Chapter 1
r
0
0 5 10 15 20 25 r
Figure 1.2. The Poisson distribution P (r | λ = 15).
Let’s derive Stirling’s approximation by an unconventional route. We start from the Poisson distribution with mean λ,
P (r | λ) = e−λ^
λr r!
r ∈ { 0 , 1 , 2 ,.. .}. (1.8)
For large λ, this distribution is well approximated – at least in the vicinity of r ' λ – by a Gaussian distribution with mean λ and variance λ:
e−λ^ λr r!
2 πλ
e−^
(r−λ)^2 2 λ (^). (1.9)
Let’s plug r = λ into this formula, then rearrange it.
e−λ^
λλ λ!
2 πλ
⇒ λ! ' λλ^ e−λ
2 πλ. (1.11)
This is Stirling’s approximation for the factorial function.
x! ' xx^ e−x
2 πx ⇔ ln x! ' x ln x − x + 12 ln 2πx. (1.12)
We have derived not only the leading order behaviour, x! ' xx^ e−x, but also, at no cost, the next-order correction term
2 πx. We now apply Stirling’s approximation to ln
r
ln
r
≡ ln
(N − r)! r!
' (N − r) ln
N − r
r
Since all the terms in this equation are logarithms, this result can be rewritten in any base. We will denote natural logarithms (loge) by ‘ln’, and logarithms Recall that log 2 x = loge x loge 2 .
Note that ∂ log 2 x ∂x = 1 loge 2
1 x .
to base 2 (log 2 ) by ‘log’. If we introduce the binary entropy function,
H 2 (x) ≡ x log
x
(1−x)
then we can rewrite the approximation (1.13) as H 2 (x)
0
1
0 0.2 0.4 0.6 0.8 (^1) x
Figure 1.3. The binary entropy function.
log
r
' N H 2 (r/N ), (1.15)
or, equivalently, (^) ( N r
' 2 N H^2 (r/N^ ). (1.16)
If we need a more accurate approximation, we can include terms of the next order from Stirling’s approximation (1.12):
log
r
' N H 2 (r/N ) − 12 log
2 πN
N −r N
r N
You can buy this book for 30 pounds or $50. See http://www.inference.phy.cam.ac.uk/mackay/itila/ for links.
4 1 — Introduction to Information Theory
transmitted message. We would prefer to have a communication channel for which this probability was zero – or so close to zero that for practical purposes it is indistinguishable from zero. Let’s consider a noisy disk drive that transmits each bit correctly with probability (1−f ) and incorrectly with probability f. This model communi- cation channel is known as the binary symmetric channel (figure 1.4).
x