SlideShare a Scribd company logo
Bayesian Analysis Fundamentals with Examples
tl;dr
Bayes enables
updating beliefs
by (fancy) counting
Bayes vs Frequentist
Bayes’ Theorem - What is it good for?
Bayes’ Theorem - What is it good for?
Bayes’ Theorem - What is it good for?
Some Zynga-ish examples
Bayesian A/B testing (T2 subsidiary)
Mixed Media Model (Cathy)
Creative Health Monitoring (Ivy)
Growth Scorecard
What to expect from this workshop
What is it?
Why is it true?
When is it useful?
How to use it?
Specifically how to use it in my models
Levels of Understanding
Who is Steve?
“Steve is very shy and withdrawn,
invariably helpful but with very little
interest in people or in the world of
reality. A meek and tidy soul, he has a
need for order and structure, and a
passion for detail.” Is Steve more likely
to be a librarian or a farmer?
10% 90%
Kahneman and Tversky
“Steve is very shy and withdrawn,
invariably helpful but with very little
interest in people or in the world of
reality. A meek and tidy soul, he has
a need for order and structure, and a
passion for detail.” Is Steve more
likely to be a librarian or a farmer?
10% 90%
Kahneman and Tversky
“Steve is very shy and withdrawn,
invariably helpful but with very little
interest in people or in the world of
reality. A meek and tidy soul, he has
a need for order and structure, and a
passion for detail.” Is Steve more
likely to be a librarian or a farmer?
10% 90%
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
20
1
Spoiler Alert
We are going to describe this in pictures
20
1
200
10
200
10
“Steve is very shy and withdrawn,
invariably helpful but with very little
interest in people or in the world of
reality. A meek and tidy soul, he has
a need for order and structure, and a
passion for detail.” Is Steve more
likely to be a librarian or a farmer?
200
10
40%
200
10
40%
10%
200
4
40%
10%
4
40%
10%
20
4
40%
10%
20
P(librarian | description) =
Heart of Bayes Theorem
All
Possibilities
All
Possibilities
fitting
evidence
P(Librarian
given the
evidence)
Heart of Bayes Theorem
All
Possibilities
All
Possibilities
fitting
evidence
P(Librarian
given the
evidence)
Heart of Bayes Theorem
For each
possibility
Count the
number of
ways evidence
can happen
Make this
ratio:
P(Librarian
given the
evidence)
When to use Bayes Rule
We have a
hypothesis
We observe some
evidence
“Steve is very shy and
withdrawn, invariably helpful
but with very little interest in
people or in the world of
reality. A meek and tidy soul,
he has a need for order and
structure, and a passion for
detail.”
We want
P(H|E)
P(hypothesis given
evidence)
Heart of Bayes Theorem
All
Possibilities
All
Possibilities
fitting
evidence
P(Librarian
given the
description)
How can we write
this more
mathematically?
Goal: P(H|E)
P(hypothesis given
evidence)
P(Librarian given
description)
Goal: P(H|E)
P(H) = 1/21
Goal: P(H|E)
Prior → P(H) = 1/21
Goal: P(H|E)
Prior → P(H) = 1/21
P(E|H) = 0.4
Goal: P(H|E)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
Goal: P(H|E)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
P(H|E)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
P(H|E) =
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# )
210
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# )
210
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H)
10
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
4
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
4
(# ) P(H) P(E|H)
4
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
(# ) P(H) P(E|H) + (# )
4
4 210
P(¬H) = 20/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
(# ) P(H) P(E|H) + (# ) P(¬H)
4
4 200
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
(# ) P(H) P(E|H) + (# ) P(¬H)P(E|¬H)
4
4 20
P(¬H) = 20/21
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) = =
(# ) P(H) P(E|H)
(# ) P(H) P(E|H) + (# ) P(¬H) P(E|¬H)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
P(H) P(E|H)
P(H) P(E|H) + P(¬H) P(E|¬H)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
P(H) P(E|H)
P(H) P(E|H) + P(¬H) P(E|¬H)
Bayes
Theorem
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
P(H) P(E|H)
P(H) P(E|H) + P(¬H) P(E|¬H)
Bayes
Theorem
P(E)
Prior → P(H) = 1/21
P(E|H) = 0.4
Likelihood
P(E|¬H) = 0.1
+
P(H|E) =
P(H) P(E|H) Bayes
Theorem
P(E)
Posterior
P(H|E) =
P(H) P(E|H) Bayes
Theorem
P(E)
P(H|E) =
P(H) P(E|H) Bayes
Theorem
P(E)
1
1
P(H|E) =
P(H) P(E|H) Bayes
Theorem
P(E)
1
1
P(H|E) =
P(H) P(E|H) Bayes
Theorem
P(E)
1
1
Final Note About Steve
Bayesian Data Analysis
in 3 easy steps!
1. For each possible explanation
of the data
2. Count all the ways data can
happen
3. Explanations with more ways
to produce the data are more
plausible (make a ratio)
Urns and Marbles - really?
For each possibility
For each possibility
First Possibility
Second
Possibility
Third Possibility
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Count ways evidence can occur
Count ways evidence can occur
Count ways evidence can occur
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Count ways evidence can occur
Bayesian Analysis Fundamentals with Examples
Make the ratio
Make the ratio
Make the ratio
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Updating
in 3 easy steps!
1. Make a model for how observations can happen. Do it
again for each possible explanation
2. Count all the ways data can happen for each
explanation
3. The relative values of step 2 give the relative
plausibility
What
proportion of
the earth is
covered by
water?
demo
1. For each possible
explanation of the
data
2. Count all the ways
data can happen
3. Make a ratio
Get more Evidence and
Update
Bayes enables
updating beliefs
by (fancy) counting
Bayes enables
updating beliefs
using MCMC
When to use Bayesian inference?
● Data is limited
○ Updating Bayesian estimates converge with modest data support
○ In large sample size limit, Bayesian and Frequentist converge
● Uncertainty is important
○ Bayesian estimates are distributions
○ Probabilities are conducive to confidence metrics
● Quantifiable prior beliefs
○ We know something about the world ahead of time
○ Easy to update if what we know changes
End of Session 1 - Questions?
Parachute
Manufacturing
Bayesian Workshop
Take-Two: Parachute Division
Strauss just announced that Take-Two is going to pivot it’s Zynga
Mobile division to solely manufacturing parachute toys, called ‘Chutes.
Our new mission is to “Connect the world through ‘Chutes”.
Manufacturing has already started, and we have the first batch fresh
off the assembly line. Uh oh! In the frenzy of the re-org, we forgot to
characterize the aerodynamic performance of this toy—namely, it’s
drag coefficient—which is a requirement by the World Aerial Toy
Association.
Legal said we are vulnerable to huge fines if we can’t provide the drag
coefficient in our Terms of Service by the time we go live with our new
toy. We have 1 hour to solve this problem!
Our goal, is to devise an experiment that uses a Bayesian approach to
quickly and confidently estimate the ‘Chute’s drag coefficient.
Aerodynamics Overview
Luckily, Take-Two has a resident Rocket
Scientist on retainer. Dr. Ryan has offered
to give some background aerodynamics
information to get us started.
First, let’s draw a Free Body Diagram.
Weight
(W)
Drag (D)
Aerodynamics Overview
Our manufacturer provided
us the weight measurement.
Equation for Drag force:
Density of air
Reference area
Velocity
Drag coefficient
What is the stable,
unaccelerated state of a ‘Chute?
When the Drag force balances
Weight, we are gliding at a
terminal velocity.
Let’s assume this happens fairly
fast after initial drop.
Weight
(W)
Drag (D)
Aerodynamics Overview
Once a ‘Chute is at a terminal
velocity, Drag = Weight. We can
solve for V.
Great, but how can we find Cd?
What if we try to measure V
through an experiment?
Weight
(W)
Drag (D)
Drag Coefficient Experiment
Proposed experiment:
Drop for a known height and record the
glide time. We know:
Frequentist approach:
Measure a bunch of distance
and time. Calculate Cd, and
report the average value.
The only
unknown is Cd
Bayesian Approach
Our experiment generates data. Our unknown
random variable 𝛉 is Cd.
Likelihood:
For a given value of Cd, what’s the probability
of generating our data? We can use our physics
model!
Prior:
Our best guess of the probability distribution of
a ‘Chute’s drag coefficient.
Posterior:
Updated guess of Cd, updated given the set of
data we collected.
Bayesian Approach
Likelihood:
Prior:
Expert consultant:
Posterior:
PyMC3 package will solve for this, and will give
us posterior distributions for Cd.
*Our experimental error recording
time t is normally distributed
Challenge
Goal: Get Strauss and Legal a Bayesian estimate of Cd!
Split up into groups of two, and conduct your experiment:
1. Clone this Databricks notebook: https://dbc-019b8f42-
900e.cloud.databricks.com/?#notebook/4116061
2. Drop the ‘Chute at least 10 times from a known height and record it’s freefall time.
Enter your data in the Databricks notebook.
3. Notice your prior distribution for Cd, given to you by your Expert Consultant
4. Run PyMC3 to calculate the posterior estimate of Cd. Record the distribution’s mean and standard
deviation.
5. Plot your posterior estimates of Cd after:
a. No data, plot the prior
b. 1 data point
c. 5 data points
d. 10 data points
We will reconvene and discuss our results after 45 minutes!
Reference Material
● Bayesian parameter estimation examples:
https://epubs.siam.org/doi/pdf/10.1137/100788604
https://cimec.org.ar/ojs/index.php/mc/article/download/5564/5542
https://arxiv.org/abs/2104.08621
● A great Bayes intro w/ Regression examples:
https://bayesball.github.io/BOOK/
https://www.bayesrulesbook.com/
● Bayesian A/B testing POC @ Zynga:
https://github-ca.corp.zynga.com/kryan/BayesRozesPOC
Appendix
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayes is
just
counting
computing
the
posterior
MCMC computing
the
posterior
Bayesian Analysis Fundamentals with Examples
MCMC
MCMC
You can evaluate the function, but you
cannot draw sample from the function
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
chi-feng.github.io
D E M O
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples
When to use Bayesian inference?
● When data is lacking
○ Frequentist: large error bars, poor estimates
○ By making more assumptions, we get to leverage more information
○ In large sample size limit, Bayesian and Frequentist approaches
converge
● When you desire levels of belief over True/False
statements
○ Bayesian approach still has distribution for parameter, even for large
sample size
○ Bayesian interpretation of probability is more intuitive to people
Bayes’ Theorem
Bayes’ Theorem
Bayes’ Theorem
Bayes’ Theorem
likelihood evidence
posterior
Observations, data, features
Outcome, label
Bayesian POV
● Experiment → prior notion + data = new (posterior) notion
● Unknown parameters → associated probabilities interpreted as
“belief” in truth
● Probabilities → how well a proposition is supported by the data
provided as evidence for it

More Related Content

PDF
An introduction to Bayesian Statistics using Python
PPT
Bayes Classification
PDF
Bayesian Learning - Naive Bayes Algorithm
PPTX
Bayesian statistics for biologists and ecologists
PPT
Uncertainty
PPT
Introduction to Bayesian Statistics.ppt
PPT
PDF
Bayesian Machine Learning & Python – Naïve Bayes (PyData SV 2013)
An introduction to Bayesian Statistics using Python
Bayes Classification
Bayesian Learning - Naive Bayes Algorithm
Bayesian statistics for biologists and ecologists
Uncertainty
Introduction to Bayesian Statistics.ppt
Bayesian Machine Learning & Python – Naïve Bayes (PyData SV 2013)

Similar to Bayesian Analysis Fundamentals with Examples (20)

PDF
Bayesian data analysis1
PPT
Cs221 lecture5-fall11
PPT
Lecture 7
PPT
Lecture 7
PDF
Warmup_New.pdf
PDF
04_NBayes-Machine Learning 10-601-1-26-2015.pptx.pdf
PPTX
Introduction to Naive Bayes Algorithm ppt
PDF
An introduction to Bayesian Statistics and its application
PDF
01.ConditionalProb.pdf in the Bayes_intro folder
PDF
01.conditional prob
PDF
“I. Conjugate priors”
PPTX
unit 3 -ML.pptx
PDF
sigir2017bayesian
PPTX
Redevelop 2019 - Debugging our biases and intuition in software development
PDF
Bayes Rule with a formula for students studying
PPTX
Probabilistic Reasoning
PDF
Frequentist inference only seems easy By John Mount
PPT
Who needs an estimate
PPTX
pydata_confernence_july_2016_modified_sunday_final
PDF
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Bayesian data analysis1
Cs221 lecture5-fall11
Lecture 7
Lecture 7
Warmup_New.pdf
04_NBayes-Machine Learning 10-601-1-26-2015.pptx.pdf
Introduction to Naive Bayes Algorithm ppt
An introduction to Bayesian Statistics and its application
01.ConditionalProb.pdf in the Bayes_intro folder
01.conditional prob
“I. Conjugate priors”
unit 3 -ML.pptx
sigir2017bayesian
Redevelop 2019 - Debugging our biases and intuition in software development
Bayes Rule with a formula for students studying
Probabilistic Reasoning
Frequentist inference only seems easy By John Mount
Who needs an estimate
pydata_confernence_july_2016_modified_sunday_final
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Ad

More from Tushar Tank (13)

PPTX
Kalman Filter Redux .
PPTX
Should you use zsh? .
PPTX
Statistical Clustering Redux - kmeans, GMM and Variational Inference
PPTX
Image Processing Background Elimination in Video Editting
PPTX
Intuition behind Markov Chain Monte Carlo
PPTX
Review of CausalImpact / Bayesian Structural Time-Series Analysis
PPTX
Tech Talk overview of xgboost and review of paper
PPTX
Shapley Tech Talk - SHAP and Shapley Discussion
PPT
Hindu ABC Book
PPTX
Statistical Clustering
PPT
Variational Inference
PPT
Time Frequency Analysis for Poets
PPTX
Kalman filter upload
Kalman Filter Redux .
Should you use zsh? .
Statistical Clustering Redux - kmeans, GMM and Variational Inference
Image Processing Background Elimination in Video Editting
Intuition behind Markov Chain Monte Carlo
Review of CausalImpact / Bayesian Structural Time-Series Analysis
Tech Talk overview of xgboost and review of paper
Shapley Tech Talk - SHAP and Shapley Discussion
Hindu ABC Book
Statistical Clustering
Variational Inference
Time Frequency Analysis for Poets
Kalman filter upload
Ad

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Pre independence Education in Inndia.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Insiders guide to clinical Medicine.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
PPH.pptx obstetrics and gynecology in nursing
Renaissance Architecture: A Journey from Faith to Humanism
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
Computing-Curriculum for Schools in Ghana
Final Presentation General Medicine 03-08-2024.pptx
Classroom Observation Tools for Teachers
Microbial diseases, their pathogenesis and prophylaxis
Pre independence Education in Inndia.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
human mycosis Human fungal infections are called human mycosis..pptx
Complications of Minimal Access Surgery at WLH
Insiders guide to clinical Medicine.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf

Bayesian Analysis Fundamentals with Examples

  • 5. Bayes’ Theorem - What is it good for?
  • 6. Bayes’ Theorem - What is it good for?
  • 7. Bayes’ Theorem - What is it good for?
  • 8. Some Zynga-ish examples Bayesian A/B testing (T2 subsidiary) Mixed Media Model (Cathy) Creative Health Monitoring (Ivy) Growth Scorecard
  • 9. What to expect from this workshop What is it? Why is it true? When is it useful? How to use it? Specifically how to use it in my models Levels of Understanding
  • 10. Who is Steve? “Steve is very shy and withdrawn, invariably helpful but with very little interest in people or in the world of reality. A meek and tidy soul, he has a need for order and structure, and a passion for detail.” Is Steve more likely to be a librarian or a farmer? 10% 90%
  • 11. Kahneman and Tversky “Steve is very shy and withdrawn, invariably helpful but with very little interest in people or in the world of reality. A meek and tidy soul, he has a need for order and structure, and a passion for detail.” Is Steve more likely to be a librarian or a farmer? 10% 90%
  • 12. Kahneman and Tversky “Steve is very shy and withdrawn, invariably helpful but with very little interest in people or in the world of reality. A meek and tidy soul, he has a need for order and structure, and a passion for detail.” Is Steve more likely to be a librarian or a farmer? 10% 90%
  • 16. 20 1
  • 17. Spoiler Alert We are going to describe this in pictures 20 1
  • 19. 200 10 “Steve is very shy and withdrawn, invariably helpful but with very little interest in people or in the world of reality. A meek and tidy soul, he has a need for order and structure, and a passion for detail.” Is Steve more likely to be a librarian or a farmer?
  • 25. Heart of Bayes Theorem All Possibilities All Possibilities fitting evidence P(Librarian given the evidence)
  • 26. Heart of Bayes Theorem All Possibilities All Possibilities fitting evidence P(Librarian given the evidence)
  • 27. Heart of Bayes Theorem For each possibility Count the number of ways evidence can happen Make this ratio: P(Librarian given the evidence)
  • 28. When to use Bayes Rule We have a hypothesis We observe some evidence “Steve is very shy and withdrawn, invariably helpful but with very little interest in people or in the world of reality. A meek and tidy soul, he has a need for order and structure, and a passion for detail.” We want P(H|E) P(hypothesis given evidence)
  • 29. Heart of Bayes Theorem All Possibilities All Possibilities fitting evidence P(Librarian given the description) How can we write this more mathematically?
  • 32. Goal: P(H|E) Prior → P(H) = 1/21
  • 33. Goal: P(H|E) Prior → P(H) = 1/21 P(E|H) = 0.4
  • 34. Goal: P(H|E) Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood
  • 35. Goal: P(H|E) Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1
  • 36. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 P(H|E)
  • 37. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 P(H|E) =
  • 38. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) =
  • 39. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) =
  • 40. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) 210
  • 41. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) 210
  • 42. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) 10
  • 43. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) 4
  • 44. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) 4 (# ) P(H) P(E|H) 4
  • 45. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) (# ) P(H) P(E|H) + (# ) 4 4 210
  • 46. P(¬H) = 20/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) (# ) P(H) P(E|H) + (# ) P(¬H) 4 4 200
  • 47. P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) (# ) P(H) P(E|H) + (# ) P(¬H)P(E|¬H) 4 4 20 P(¬H) = 20/21
  • 48. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = = (# ) P(H) P(E|H) (# ) P(H) P(E|H) + (# ) P(¬H) P(E|¬H)
  • 49. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = P(H) P(E|H) P(H) P(E|H) + P(¬H) P(E|¬H)
  • 50. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = P(H) P(E|H) P(H) P(E|H) + P(¬H) P(E|¬H) Bayes Theorem
  • 51. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = P(H) P(E|H) P(H) P(E|H) + P(¬H) P(E|¬H) Bayes Theorem P(E)
  • 52. Prior → P(H) = 1/21 P(E|H) = 0.4 Likelihood P(E|¬H) = 0.1 + P(H|E) = P(H) P(E|H) Bayes Theorem P(E) Posterior
  • 53. P(H|E) = P(H) P(E|H) Bayes Theorem P(E)
  • 54. P(H|E) = P(H) P(E|H) Bayes Theorem P(E) 1 1
  • 55. P(H|E) = P(H) P(E|H) Bayes Theorem P(E) 1 1
  • 56. P(H|E) = P(H) P(E|H) Bayes Theorem P(E) 1 1 Final Note About Steve
  • 57. Bayesian Data Analysis in 3 easy steps! 1. For each possible explanation of the data 2. Count all the ways data can happen 3. Explanations with more ways to produce the data are more plausible (make a ratio)
  • 58. Urns and Marbles - really?
  • 68. Count ways evidence can occur
  • 69. Count ways evidence can occur
  • 70. Count ways evidence can occur
  • 73. Count ways evidence can occur
  • 81. Bayesian Updating in 3 easy steps! 1. Make a model for how observations can happen. Do it again for each possible explanation 2. Count all the ways data can happen for each explanation 3. The relative values of step 2 give the relative plausibility
  • 82. What proportion of the earth is covered by water? demo
  • 83. 1. For each possible explanation of the data 2. Count all the ways data can happen 3. Make a ratio Get more Evidence and Update
  • 86. When to use Bayesian inference? ● Data is limited ○ Updating Bayesian estimates converge with modest data support ○ In large sample size limit, Bayesian and Frequentist converge ● Uncertainty is important ○ Bayesian estimates are distributions ○ Probabilities are conducive to confidence metrics ● Quantifiable prior beliefs ○ We know something about the world ahead of time ○ Easy to update if what we know changes
  • 87. End of Session 1 - Questions?
  • 89. Take-Two: Parachute Division Strauss just announced that Take-Two is going to pivot it’s Zynga Mobile division to solely manufacturing parachute toys, called ‘Chutes. Our new mission is to “Connect the world through ‘Chutes”. Manufacturing has already started, and we have the first batch fresh off the assembly line. Uh oh! In the frenzy of the re-org, we forgot to characterize the aerodynamic performance of this toy—namely, it’s drag coefficient—which is a requirement by the World Aerial Toy Association. Legal said we are vulnerable to huge fines if we can’t provide the drag coefficient in our Terms of Service by the time we go live with our new toy. We have 1 hour to solve this problem! Our goal, is to devise an experiment that uses a Bayesian approach to quickly and confidently estimate the ‘Chute’s drag coefficient.
  • 90. Aerodynamics Overview Luckily, Take-Two has a resident Rocket Scientist on retainer. Dr. Ryan has offered to give some background aerodynamics information to get us started. First, let’s draw a Free Body Diagram. Weight (W) Drag (D)
  • 91. Aerodynamics Overview Our manufacturer provided us the weight measurement. Equation for Drag force: Density of air Reference area Velocity Drag coefficient What is the stable, unaccelerated state of a ‘Chute? When the Drag force balances Weight, we are gliding at a terminal velocity. Let’s assume this happens fairly fast after initial drop. Weight (W) Drag (D)
  • 92. Aerodynamics Overview Once a ‘Chute is at a terminal velocity, Drag = Weight. We can solve for V. Great, but how can we find Cd? What if we try to measure V through an experiment? Weight (W) Drag (D)
  • 93. Drag Coefficient Experiment Proposed experiment: Drop for a known height and record the glide time. We know: Frequentist approach: Measure a bunch of distance and time. Calculate Cd, and report the average value. The only unknown is Cd
  • 94. Bayesian Approach Our experiment generates data. Our unknown random variable 𝛉 is Cd. Likelihood: For a given value of Cd, what’s the probability of generating our data? We can use our physics model! Prior: Our best guess of the probability distribution of a ‘Chute’s drag coefficient. Posterior: Updated guess of Cd, updated given the set of data we collected.
  • 95. Bayesian Approach Likelihood: Prior: Expert consultant: Posterior: PyMC3 package will solve for this, and will give us posterior distributions for Cd. *Our experimental error recording time t is normally distributed
  • 96. Challenge Goal: Get Strauss and Legal a Bayesian estimate of Cd! Split up into groups of two, and conduct your experiment: 1. Clone this Databricks notebook: https://dbc-019b8f42- 900e.cloud.databricks.com/?#notebook/4116061 2. Drop the ‘Chute at least 10 times from a known height and record it’s freefall time. Enter your data in the Databricks notebook. 3. Notice your prior distribution for Cd, given to you by your Expert Consultant 4. Run PyMC3 to calculate the posterior estimate of Cd. Record the distribution’s mean and standard deviation. 5. Plot your posterior estimates of Cd after: a. No data, plot the prior b. 1 data point c. 5 data points d. 10 data points We will reconvene and discuss our results after 45 minutes!
  • 97. Reference Material ● Bayesian parameter estimation examples: https://epubs.siam.org/doi/pdf/10.1137/100788604 https://cimec.org.ar/ojs/index.php/mc/article/download/5564/5542 https://arxiv.org/abs/2104.08621 ● A great Bayes intro w/ Regression examples: https://bayesball.github.io/BOOK/ https://www.bayesrulesbook.com/ ● Bayesian A/B testing POC @ Zynga: https://github-ca.corp.zynga.com/kryan/BayesRozesPOC
  • 107. MCMC
  • 108. MCMC You can evaluate the function, but you cannot draw sample from the function
  • 126. When to use Bayesian inference? ● When data is lacking ○ Frequentist: large error bars, poor estimates ○ By making more assumptions, we get to leverage more information ○ In large sample size limit, Bayesian and Frequentist approaches converge ● When you desire levels of belief over True/False statements ○ Bayesian approach still has distribution for parameter, even for large sample size ○ Bayesian interpretation of probability is more intuitive to people
  • 131. Bayesian POV ● Experiment → prior notion + data = new (posterior) notion ● Unknown parameters → associated probabilities interpreted as “belief” in truth ● Probabilities → how well a proposition is supported by the data provided as evidence for it