# Bayes' Rule

**A tutorial introduction to Bayesian analysis**

## About this book

What does a medical test tell us about the chances of having a particular disease?

How can we tell if a spoken phrase is, "four candles" or "fork handles"?

How do we a perceive a three-dimensional world from from the two-dimensional images on our retinas?

The short answer is Bayes' rule, which transforms meaningless statistics and raw data into useful information. Discovered by an 18th century mathematician and preacher, Bayes' rule is a cornerstone of modern probability theory. In this richly illustrated book, intuitive visual representations of real-world examples are used to show how Bayes' rule is actually a form of common sense reasoning.

The tutorial style of writing, combined with a comprehensive glossary, makes this an ideal primer for novices who wish to gain an intuitive understanding of Bayesian analysis. As an aid to understanding, online computer code (in MATLAB, Python and R) reproduces key numerical results and diagrams.

Stone's book is renowned for its visually engaging style of presentation, which stems from teaching Bayes’ rule to psychology students for over 10 years as a university lecturer.

The books below contain identical text, but Bayes' Rule with MatLab, Bayes' Rule with Python (version 3.5) and Bayes' Rule with R include code snippets (linked below), which reproduce key figures and numerical results.

Available as ebook, paperback and hardback.

## Contents

**Preface**

**1. An introduction to Bayes' rule**

1.1 Example 1: Poxy diseases

1.2 Example 2: Forkandles

1.3 Example 3: Flipping coins

1.4 Example 4: Light craters

1.5 Forward and inverse probability

**2. Bayes’ rule in pictures**

2.1 Random variables

2.2 The rules of probability

2.3 Random variables and coin flips

2.4 Joint probability and coin flips

2.5 Probability as geometric area

2.6 Bayes' rule from Venn diagrams

2.7 Bayes' rule and the medical test

**3. Discrete parameter values**

3.1 Joint probability functions

3.2 Patient questions

3.3 Deriving Bayes' rule

3.4 Using Bayes' rule

3.5 Bayes' rule and the joint distribution

**4. Continuous parameter values**

4.1 A continuous likelihood function

4.2 A binomial prior probability density function

4.3 A posterior probability density function

4.4 A uniform prior probability density function

4.5 MAP estimates are not aﬀected by constants

4.6 Finding the MAP estimate analytically

4.7 Evolution of the posterior

4.8 Reference priors

4.9 Loss functions

**5. Gaussian parameter estimation**

5.1 The Gaussian distribution

5.2 Estimating the population mean

5.3 Error bars for Gaussian distributions

5.4 Regression as parameter estimation

**6. A bird's-eye view of Bayes' rule**

6.1 Joint Gaussian distributions

6.2 A bird's-eye view of joint distributions

6.3 A bird's-eye view of Bayes' rule

6.4 Slicing through joint distributions

6.5 Statistical independence

**7. Bayesian wars**

7.1 The nature of probability

7.2 Subjective probability

7.3 Bayesian wars

7.4 A very short history of Bayes' rule

**Further reading**

**Appendices**

A. Glossary

B. Mathematical symbols

C. The rules of probability

D. Probability density functions

E. The binomial

F. The Gaussian

G. Least-squares estimation

H. Reference priors

I. MatLab code

**References**

**Index**

## Bayes' Rule

Sebtel Press, 2013

ISBN: 9780956372840

ISBN: 9780956372895

Download Chapter 1 (PDF, 3.1MB)

Download Chapter 1 in epub format (EPUB, 4.7MB)

## Bayes' Rule with MatLab

Sebtel Press, 2015

ISBN: 978-0993367908

Download Chapter 1 (PDF, 1.8MB)

**MatLab code**

Version 7.5

Code for Bayesian estimation of the parameter values of a binomial distribution (M, 3KB)

Code for Bayesian estimation of parameter values for linear regression analysis (M, 3KB)

All code snippets included with this version of the book (ZIP, 21KB)

## Bayes' Rule with Python

Sebtel Press, 2016

ISBN: 978-0993367939

Download Chapter 1 (PDF, 2.2MB)

**Python code**

Version 3.5

All code snippets included with this version of the book (ZIP, 2.2MB)

## Bayes' Rule with R

Sebtel Press, 2016

ISBN: 978-0993367946

Download Chapter 1 (PDF, 2.1MB)

**R code**

All code snippets included with this version of the book (ZIP, 34KB)

## Reviews

"An accessible introduction to Bayesian analysis, providing a solid foundation in this key area."

**Journal of the Royal Statistical Society****, 2015**

"Interesting, and very easy to read, *Bayes' Rule* serves as an excellent primer for students and professionals."

**'Top ten math books on Bayesian analysis', July 2014**

"An excellent first step for readers with little background in the topic."

**Computing Reviews****, June 2014**

"An excellent book... Highly recommended."

**CHOICE: Academic Reviews Online****, February 2014**

"*Bayes' Rule* explains in a very easy to follow manner the basics of Bayesian analysis."

**Dr Inigo Arregui, Ramon y Cajal Researcher, Institute of Astrophysics, Spain**

"A crackingly clear tutorial for beginners. Exactly the sort of book required for those taking their first steps in Bayesian analysis."

**Dr Paul A. Warren, School of Psychological Sciences, University of Manchester**

"This book is eminently readable. It introduces the Bayesian approach to addressing statistical issues without using any advanced mathematics, which should make it accessible to students from a wide range of backgrounds, including biological and social sciences."

**Dr Devinder Sivia, Lecturer in Mathematics, St John's College, Oxford University and author of ****Data analysis: a Bayesian tutorial**

"For those with a limited mathematical background, Stone's book provides an ideal introduction to the main concepts of Bayesian analysis."

**Dr Peter M. Lee, Department of Mathematics, University of York and author of ****Bayesian statistics: an introduction**

"Bayesian analysis involves concepts which can be hard for the uninitiated to grasp. Stone's patient pedagogy and gentle examples convey these concepts with uncommon lucidity."

**Dr Charles Fox, Department of Computer Science, the University of Sheffield**