Information Science and Statistics Series Editors: M. Jordan J. Kleinberg B. Scho¨lkopf Information Science and Statistics Akaike and Kitagawa: The Practice of Time Series Analysis. Bishop: Pattern Recognition and Machine Learning. Cowell, Dawid, Lauritzen, and Spiegelhalter: Probabilistic Networks and Expert Systems. Doucet, de Freitas, and Gordon: Sequential Monte Carlo Methods in Practice. Fine: Feedforward Neural Network Methodology. Hawkins and Olwell: Cumulative Sum Charts and Charting for Quality Improvement. Jensen:Bayesian Networks and Decision Graphs. Marchette: Computer Intrusion Detection and Network Monitoring: A Statistical Viewpoint. Rubinstein and Kroese: The Cross-Entropy Method: A Unified Approach to Combinatorial Optimization, Monte Carlo Simulation, and Machine Learning. Studený: Probabilistic Conditional Independence Structures. Vapnik: The Nature of Statistical Learning Theory, Second Edition. Wallace: Statistical and Inductive Inference by Minimum Massage Length. Christopher M. Bishop Pattern Recognition and Machine Learning ChristopherM.BishopF.R.Eng. AssistantDirector MicrosoftResearchLtd CambridgeCB30FB,U.K. [email protected] http://research.microsoft.com/(cid:1)cmbishop SeriesEditors MichaelJordan ProfessorJonKleinberg BernhardScho¨lkopf DepartmentofComputer DepartmentofComputer MaxPlanckInstitutefor ScienceandDepartment Science BiologicalCybernetics ofStatistics CornellUniversity Spemannstrasse38 UniversityofCalifornia, Ithaca,NY14853 72076Tu¨bingen Berkeley USA Germany Berkeley,CA94720 USA LibraryofCongressControlNumber:2006922522 ISBN-10:0-387-31073-8 ISBN-13:978-0387-31073-2 Printedonacid-freepaper. ©2006SpringerScience+BusinessMedia,LLC Allrightsreserved.Thisworkmaynotbetranslatedorcopiedinwholeorinpartwithoutthewrittenpermissionofthepublisher (SpringerScience+BusinessMedia,LLC,233SpringStreet,NewYork,NY10013,USA),exceptforbriefexcerptsinconnection withreviewsorscholarlyanalysis.Useinconnectionwithanyformofinformationstorageandretrieval,electronicadaptation, computersoftware,orbysimilarordissimilarmethodologynowknownorhereafterdevelopedisforbidden. Theuseinthispublicationoftradenames,trademarks,servicemarks,andsimilarterms,eveniftheyarenotidentifiedassuch, isnottobetakenasanexpressionofopinionastowhetherornottheyaresubjecttoproprietaryrights. PrintedinSingapore. (KYO) 9 8 7 6 5 4 3 2 1 springer.com Thisbookisdedicatedtomyfamily: Jenna,Mark,andHugh Totaleclipseofthesun,Antalya,Turkey,29March2006. Preface Pattern recognition has its origins in engineering, whereas machine learning grew out of computer science. However, these activities can be viewed as two facets of the same field, and together they have undergone substantial development over the pasttenyears. Inparticular,Bayesianmethodshavegrownfromaspecialistnicheto becomemainstream, whilegraphicalmodelshaveemergedasageneralframework fordescribingandapplyingprobabilisticmodels. Also,thepracticalapplicabilityof Bayesianmethodshasbeengreatlyenhancedthroughthedevelopmentofarangeof approximateinferencealgorithmssuchasvariationalBayesandexpectationpropa- gation. Similarly,newmodelsbasedonkernelshavehadsignificantimpactonboth algorithmsandapplications. Thisnewtextbookreflectstheserecentdevelopmentswhileprovidingacompre- hensive introduction to the fields of pattern recognition and machine learning. It is aimedatadvancedundergraduatesorfirstyearPhDstudents,aswellasresearchers andpractitioners,andassumesnopreviousknowledgeofpatternrecognitionorma- chinelearningconcepts. Knowledgeofmultivariatecalculusandbasiclinearalgebra isrequired,andsomefamiliaritywithprobabilitieswouldbehelpfulthoughnotes- sentialasthebookincludesaself-containedintroductiontobasicprobabilitytheory. Becausethisbookhasbroadscope,itisimpossibletoprovideacompletelistof references,andinparticularnoattempthasbeenmadetoprovideaccuratehistorical attribution of ideas. Instead, the aim has been to give references that offer greater detailthanispossiblehereandthathopefullyprovideentrypointsintowhat,insome cases,isaveryextensiveliterature. Forthisreason,thereferencesareoftentomore recenttextbooksandreviewarticlesratherthantooriginalsources. The book is supported by a great deal of additional material, including lecture slides as well as the complete set of figures used in the book, and the reader is encouragedtovisitthebookwebsiteforthelatestinformation: http://research.microsoft.com/∼cmbishop/PRML vii viii PREFACE Exercises The exercises that appear at the end of every chapter form an important com- ponent of the book. Each exercise has been carefully chosen to reinforce concepts explainedinthetextortodevelopandgeneralizetheminsignificantways,andeach is graded according to difficulty ranging from ((cid:1)), which denotes a simple exercise taking a few minutes to complete, through to ((cid:1)(cid:1)(cid:1)), which denotes a significantly morecomplexexercise. It has been difficult to know to what extent these solutions should be made widely available. Those engaged in self study will find worked solutions very ben- eficial, whereas many course tutors request that solutions be available only via the publisher so that the exercises may be used in class. In order to try to meet these conflictingrequirements,thoseexercisesthathelpamplifykeypointsinthetext,or thatfillinimportantdetails,havesolutionsthatareavailableasaPDFfilefromthe book web site. Such exercises are denoted by www. Solutions for the remaining exercises are available to course tutors by contacting the publisher (contact details are given on the book web site). Readers are strongly encouraged to work through theexercisesunaided,andtoturntothesolutionsonlyasrequired. Although this book focuses on concepts and principles, in a taught course the students should ideally have the opportunity to experiment with some of the key algorithms using appropriate data sets. A companion volume (Bishop and Nabney, 2008) will deal with practical aspects of pattern recognition and machine learning, and will be accompanied by Matlab software implementing most of the algorithms discussedinthisbook. Acknowledgements First of all I would like to express my sincere thanks to Markus Svense´n who has provided immense help with preparation of figures and with the typesetting of thebookinLATEX. Hisassistancehasbeeninvaluable. IamverygratefultoMicrosoftResearchforprovidingahighlystimulatingre- searchenvironmentandforgivingmethefreedomtowritethisbook(theviewsand opinions expressed in this book, however, are my own and are therefore not neces- sarilythesameasthoseofMicrosoftoritsaffiliates). Springer has provided excellent support throughout the final stages of prepara- tionofthisbook,andIwouldliketothankmycommissioningeditorJohnKimmel forhissupportandprofessionalism,aswellasJosephPilieroforhishelpindesign- ingthecoverandthetextformatandMaryAnnBricknerforhernumerouscontribu- tionsduringtheproductionphase. Theinspirationforthecoverdesigncamefroma discussionwithAntonioCriminisi. I also wish to thank Oxford University Press for permission to reproduce ex- cerpts from an earlier textbook, Neural Networks for Pattern Recognition (Bishop, 1995a). The images of the Mark 1 perceptron and of Frank Rosenblatt are repro- ducedwiththepermissionofArvinCalspanAdvancedTechnologyCenter. Iwould also like to thank Asela Gunawardana for plotting the spectrogram in Figure 13.1, and Bernhard Scho¨lkopf for permission to use his kernel PCA code to plot Fig- ure12.17. PREFACE ix Many people have helped by proofreading draft material and providing com- mentsandsuggestions,includingShivaniAgarwal,Ce´dricArchambeau,ArikAzran, Andrew Blake, Hakan Cevikalp, Michael Fourman, Brendan Frey, Zoubin Ghahra- mani, Thore Graepel, Katherine Heller, Ralf Herbrich, Geoffrey Hinton, Adam Jo- hansen, Matthew Johnson, Michael Jordan, Eva Kalyvianaki, Anitha Kannan, Julia Lasserre,DavidLiu,TomMinka,IanNabney,TonatiuhPena,YuanQi,SamRoweis, BalajiSanjiya,TobySharp,AnaCostaeSilva,DavidSpiegelhalter,JayStokes,Tara Symeonides,MartinSzummer,MarshallTappen,IlkayUlusoy,ChrisWilliams,John Winn,andAndrewZisserman. Finally, I would like to thank my wife Jenna who has been hugely supportive throughouttheseveralyearsithastakentowritethisbook. ChrisBishop Cambridge February2006 Mathematical notation I have tried to keep the mathematical content of the book to the minimum neces- sarytoachieveaproperunderstandingofthefield. However,thisminimumlevelis nonzero, and it should be emphasized that a good grasp of calculus, linear algebra, andprobabilitytheoryisessentialforaclearunderstandingofmodernpatternrecog- nition and machine learning techniques. Nevertheless, the emphasis in this book is onconveyingtheunderlyingconceptsratherthanonmathematicalrigour. I havetried touseaconsistent notationthroughout thebook, although attimes this means departing from some of the conventions used in the corresponding re- search literature. Vectors are denoted by lower case bold Roman letters such as x, and all vectors are assumed to be column vectors. A superscript T denotes the transpose of a matrix or vector, so that xT will be a row vector. Uppercase bold roman letters, such as M, denote matrices. The notation (w1,...,wM) denotes a row vector with M elements, while the corresponding column vector is written as w =(w1,...,wM)T. The notation [a,b] is used to denote the closed interval from a to b, that is the intervalincludingthevaluesaandbthemselves,while(a,b)denotesthecorrespond- ingopeninterval, thatistheintervalexcludingaandb. Similarly, [a,b)denotesan interval that includes a but excludes b. For the most part, however, there will be littleneedtodwellonsuchrefinementsaswhethertheendpointsofanintervalare includedornot. The M × M identity matrix (also known as the unit matrix) is denoted IM, whichwillbeabbreviatedtoIwherethereisnoambiguityaboutitdimensionality. IthaselementsIij thatequal1ifi=j and0ifi(cid:2)=j. A functional is denoted f[y] where y(x) is some function. The concept of a functionalisdiscussedinAppendixD. Thenotationg(x) = O(f(x))denotesthat|f(x)/g(x)|isboundedasx → ∞. Forinstanceifg(x)=3x2+2,theng(x)=O(x2). Theexpectationofafunctionf(x,y)withrespecttoarandomvariablexisde- notedbyEx[f(x,y)]. Insituationswherethereisnoambiguityastowhichvariable is being averaged over, this will be simplified by omitting the suffix, for instance xi