Bayesian Statistics the Fun Way

Bayesian Statistics the Fun Way

Understanding Statistics and Probability with Star Wars, LEGO, and Rubber Ducks
by Will Kurt
July 2019, 256 pp.
ISBN-13: 
9781593279561

Look Inside!

Bayesian Statistics The Fun WayBayesian Statistics The Fun WayBayesian Statistics The Fun WayBayesian Statistics The Fun WayBayesian Statistics The Fun Way

Download Chapter 7: Bayes' Theorem with LEGO

Author interview in This is not a Monad tutorial.

Get the most from your data, and have fun doing it

Probability and statistics are increasingly important in a huge range of professions. But many people use data in ways they don’t even understand, meaning they aren’t getting the most from it. Bayesian Statistics the Fun Way will change that.

This book will give you a complete understanding of Bayesian statistics through simple explanations and un-boring examples. Find out the probability of UFOs landing in your garden, how likely Han Solo is to survive a flight through an asteroid belt, how to win an argument about conspiracy theories, and whether a burglary really was a burglary, to name a few examples.

By using these off-the-beaten-track examples, the author actually makes learning statistics fun. And you’ll learn real skills, like how to:

  • How to measure your own level of uncertainty in a conclusion or belief
  • Calculate Bayes theorem and understand what it’s useful for
  • Find the posterior, likelihood, and prior to check the accuracy of your conclusions
  • Calculate distributions to see the range of your data
  • Compare hypotheses and draw reliable conclusions from them

Next time you find yourself with a sheaf of survey results and no idea what to do with them, turn to Bayesian Statistics the Fun Way to get the most value from your data.

Author Bio 

Will Kurt works as a data scientist at Wayfair, and has been using Bayesian statistics to solve real business problems for over half a decade. He frequently blogs about probability on his website, CountBayesie.com. Kurt is the author of Get Programming with Haskell (Manning Publications) and lives in Boston, Massachusetts.

Table of contents 

Introduction

Part 1: Introduction to Probability
Chapter 1: What Do You Believe and How Do You Change it?
Chapter 2: Measuring Uncertainty
Chapter 3: The Logic of Uncertainty
Chapter 4: Probability Distributions 1
Chapter 5: Probability Distributions 2

Part 2: Bayesian Probability and Prior Probabilities
Chapter 6: Conditional Probability
Chapter 7: Bayes' Theorem with LEGO
Chapter 8: Posterior, Likelihood, and Prior
Chapter 9: Working with Prior Probability Distributions

Part 3: Parameter Estimation
Chapter 10: Intro to Parameter Estimation
Chapter 11: Measuring the Spread of Data
Chapter 12: Normal Distribution and Confidence
Chapter 13: Tools of Parameter Estimation
Chapter 14: Parameter Estimation with Priors

Part 4: Hypothesis Testing: The Heart of Statistics
Chapter 15: From Parameter Estimation to Hypothesis Testing
Chapter 16: Comparing Hypotheses with Bayes Factor
Chapter 17: Bayesian Reasoning in the Twilight Zone
Chapter 18: When Data Doesn't Convince You
Chapter 19: From Hypothesis Testing to Parameter Estimation

Appendix A: A Crash Course in R
Appendix B: Enough Calculus to Get By

View the detailed Table of Contents
View the Index

Reviews 

"An excellent introduction to subjects critical to all data scientists." —Inside Big Data

Author interview in This is not a Monad tutorial.

Featured in Great Lakes Geek.

Updates 

Page 29:
The line:
So, using our die roll and coin toss example, the probability of rolling a number less than 6 or flipping a heads is:
Should now read:
So, using our die roll and coin toss example, the probability of rolling a number equal to 6 or flipping a heads is:

Page 41:
The y axis on Figure 4.2:
B(k; 10, 1/2)
Should now read:
B(k; 10, 1/6)

And the caption for Figure 4.2:
The probability of getting a 6 when rolling a six-sided die 10 times
Should now read:
The probability of getting 6 k times when rolling a six-sided die 10 times

Page 51:
The line:
What we get in the end is a function that describes the probability of each possible hypothesis for our true belief in the probability of getting two heads from the box...
Should now read:
What we get in the end is a function that describes the probability of each possible hypothesis for our true belief in the probability of getting two coins from the box...

Page 71:
The equation:
numberOfRedStuds = P (yellow | red) × numberOfRedStuds = 1/5 × 20 = 4
Should now read:
numberOfRedUnderYellow = P(yellow | red) × numberOfRedStuds = 1/5 × 20 = 4

Page 87:
The equation:
Beta (20002,7401) = Beta (2 + 20000, 7400 + 1)
Should now read:
Beta (20002,7441) = Beta (2 + 20000, 7440 + 1)

Page 88:
The top label on Figure 9-3:
Distribution of our prior belief Beta(2+20000,7400+1)
Should now read:
Distribution of our posterior belief Beta(2+20000,7440+1)"

Page 105:
The last row of Table 11-1:
2.80. -0.16
Should now read:
2.80. -0.2

And the equation:
a<subscript 1> and b<subscript 1>
Should now read:
a<subscript i> and b<subscript i>

Page 106:
The second equation:
2.08
Should now read:
0.416

Page 127:
In the top code block, the second code line:
xs.all <- seq(0,1,by=0.0001)
Should be deleted

Page 130:
The reference to "Figure 3-5" should read "Figure 13-5"

Page 164:
The line:
The prior odds look like this:
Should now read:
The probabilities look like this:

And in the last equation, the fraction:
223/370,000
Should now read:
245/370,000

And the line:
This result shows that H2 is about 1,659 times more likely than H1.
Should now read:
This result shows that H2 is about 1,510 times more likely than H1.

Page 224:
The lines:
The slope of 5 means that for every time x grows by 1, y grows by 5; 4.8 is the point at which the line crosses the x-axis. In this example, we’d interpret this formula as s(t) = 5t + 4.8, meaning that for every mile you travel you accelerate by 5 mph, and that you started off at 4.8 mph. Since you’ve run half a mile, using this simple formula, we can figure out:
Should now read:
The slope of 5 means that for every time x grows by 1, y grows by 5; 4.8 is the point at which the line crosses the y-axis. In this example, we’d interpret this formula as s(t) = 5t + 4.8, meaning that for every mile you travel you accelerate by 5 mph, and that you started off at 4.8 mph. Since you’ve run half an hour, using this simple formula, we can figure out:

Page 236:
The line :
Luckily we already did all this work earlier in the chapter, so we know that (A) = 4/1,000 and P(B) = 3/(100,000).
Should now read:
Luckily we already did all this work earlier in the chapter, so we know that (A) = 8/100 and P(B) = 3/(100,000).

Page 237:
The line:
Plugging in our numbers, we get an answer of 100,747/25,000,000 or 0.00403.
Should now read:
Plugging in our numbers, we get an answer of 800,276/10,000,000 or 0.0800276.

Page 242: In the last line of code on the page, which reads:
temp.sd <- my.sd(temp.data)

Should read:
temp.sd <- sd(temp.data)

Page 250:
The second equation:
P (D | H2) = 0.63 × 0.55 × 0.49 = 0.170
Should now read:
P (D | H2) = 0.94 x 0.83 x 0.49 = 0.382

And the line:
This means that given the Bayes factor alone, vestibular schwannoma is a roughly two times better explanation than labyrinthitis. Now we have to look at the odds ratio:
Should now read:
This means that given the Bayes factor alone, vestibular schwannoma is a roughly four times better explanation than labyrinthitis. Now we have to look at the prior odds ratio:

Page 251:
The line:
The end result is that labyrinthititis is only a slightly better explanation than vestibular schwannoma.
Should now read:
The end result is that vestibular schwannoma is only a slightly better explanation than labyrinthitis.

Page 254:
In the top equation, the content should now read:
50 = 9/19 × BF BF = 950

And the second line of the first code block:
hypotheses <- seq(0,1,by=0.01)
Should now read:
hypotheses <- seq(0,1,by=dx)