SlideShare a Scribd company logo
1 of 131
Download to read offline
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%
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
Count ways evidence can occur
Count ways evidence can occur
Count ways evidence can occur
Count ways evidence can occur
Make the ratio
Make the ratio
Make the ratio
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
Bayes is
just
counting
computing
the
posterior
MCMC computing
the
posterior
MCMC
MCMC
You can evaluate the function, but you
cannot draw sample from the function
chi-feng.github.io
D E M O
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

Similar to Bayesian Analysis Fundamentals with Examples

Cs221 lecture5-fall11
Cs221 lecture5-fall11Cs221 lecture5-fall11
Cs221 lecture5-fall11darwinrlo
 
Lecture 7
Lecture 7Lecture 7
Lecture 7butest
 
Lecture 7
Lecture 7Lecture 7
Lecture 7butest
 
“I. Conjugate priors”
“I. Conjugate priors”“I. Conjugate priors”
“I. Conjugate priors”Steven Scott
 
01.conditional prob
01.conditional prob01.conditional prob
01.conditional probSteven Scott
 
01.ConditionalProb.pdf in the Bayes_intro folder
01.ConditionalProb.pdf in the Bayes_intro folder01.ConditionalProb.pdf in the Bayes_intro folder
01.ConditionalProb.pdf in the Bayes_intro folderSteven Scott
 
Redevelop 2019 - Debugging our biases and intuition in software development
Redevelop 2019 - Debugging our biases and intuition in software developmentRedevelop 2019 - Debugging our biases and intuition in software development
Redevelop 2019 - Debugging our biases and intuition in software developmentDave Hulbert
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic ReasoningTameem Ahmad
 
Frequentist inference only seems easy By John Mount
Frequentist inference only seems easy By John MountFrequentist inference only seems easy By John Mount
Frequentist inference only seems easy By John MountChester Chen
 
Who needs an estimate
Who needs an estimateWho needs an estimate
Who needs an estimateMatt Heusser
 
pydata_confernence_july_2016_modified_sunday_final
pydata_confernence_july_2016_modified_sunday_finalpydata_confernence_july_2016_modified_sunday_final
pydata_confernence_july_2016_modified_sunday_finalAustin Powell
 
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...Kyle Pearce
 
Introduction To Algebra 1
Introduction To Algebra 1Introduction To Algebra 1
Introduction To Algebra 1danika_laxamana
 
Expectations (Algebra 1)
Expectations (Algebra 1)Expectations (Algebra 1)
Expectations (Algebra 1)rfant
 

Similar to Bayesian Analysis Fundamentals with Examples (20)

Cs221 lecture5-fall11
Cs221 lecture5-fall11Cs221 lecture5-fall11
Cs221 lecture5-fall11
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Warmup_New.pdf
Warmup_New.pdfWarmup_New.pdf
Warmup_New.pdf
 
“I. Conjugate priors”
“I. Conjugate priors”“I. Conjugate priors”
“I. Conjugate priors”
 
01.conditional prob
01.conditional prob01.conditional prob
01.conditional prob
 
01.ConditionalProb.pdf in the Bayes_intro folder
01.ConditionalProb.pdf in the Bayes_intro folder01.ConditionalProb.pdf in the Bayes_intro folder
01.ConditionalProb.pdf in the Bayes_intro folder
 
unit 3 -ML.pptx
unit 3 -ML.pptxunit 3 -ML.pptx
unit 3 -ML.pptx
 
sigir2017bayesian
sigir2017bayesiansigir2017bayesian
sigir2017bayesian
 
Redevelop 2019 - Debugging our biases and intuition in software development
Redevelop 2019 - Debugging our biases and intuition in software developmentRedevelop 2019 - Debugging our biases and intuition in software development
Redevelop 2019 - Debugging our biases and intuition in software development
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic Reasoning
 
Frequentist inference only seems easy By John Mount
Frequentist inference only seems easy By John MountFrequentist inference only seems easy By John Mount
Frequentist inference only seems easy By John Mount
 
Who needs an estimate
Who needs an estimateWho needs an estimate
Who needs an estimate
 
pydata_confernence_july_2016_modified_sunday_final
pydata_confernence_july_2016_modified_sunday_finalpydata_confernence_july_2016_modified_sunday_final
pydata_confernence_july_2016_modified_sunday_final
 
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
Digging Deep Into Ratios and Proportional Reasoning in the Middle Grades - NC...
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Bayesian inference
Bayesian inferenceBayesian inference
Bayesian inference
 
ISBA 2016: Foundations
ISBA 2016: FoundationsISBA 2016: Foundations
ISBA 2016: Foundations
 
Introduction To Algebra 1
Introduction To Algebra 1Introduction To Algebra 1
Introduction To Algebra 1
 
Expectations (Algebra 1)
Expectations (Algebra 1)Expectations (Algebra 1)
Expectations (Algebra 1)
 

More from Tushar Tank

Image Processing Background Elimination in Video Editting
Image Processing Background Elimination in Video EdittingImage Processing Background Elimination in Video Editting
Image Processing Background Elimination in Video EdittingTushar Tank
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsTushar Tank
 
Review of CausalImpact / Bayesian Structural Time-Series Analysis
Review of CausalImpact / Bayesian Structural Time-Series AnalysisReview of CausalImpact / Bayesian Structural Time-Series Analysis
Review of CausalImpact / Bayesian Structural Time-Series AnalysisTushar Tank
 
Tech Talk overview of xgboost and review of paper
Tech Talk overview of xgboost and review of paperTech Talk overview of xgboost and review of paper
Tech Talk overview of xgboost and review of paperTushar Tank
 
Shapley Tech Talk - SHAP and Shapley Discussion
Shapley Tech Talk - SHAP and Shapley DiscussionShapley Tech Talk - SHAP and Shapley Discussion
Shapley Tech Talk - SHAP and Shapley DiscussionTushar Tank
 
Statistical Clustering
Statistical ClusteringStatistical Clustering
Statistical ClusteringTushar Tank
 
Variational Inference
Variational InferenceVariational Inference
Variational InferenceTushar Tank
 
Time Frequency Analysis for Poets
Time Frequency Analysis for PoetsTime Frequency Analysis for Poets
Time Frequency Analysis for PoetsTushar Tank
 
Kalman filter upload
Kalman filter uploadKalman filter upload
Kalman filter uploadTushar Tank
 

More from Tushar Tank (10)

Image Processing Background Elimination in Video Editting
Image Processing Background Elimination in Video EdittingImage Processing Background Elimination in Video Editting
Image Processing Background Elimination in Video Editting
 
Intuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov ChainsIntuition behind Monte Carlo Markov Chains
Intuition behind Monte Carlo Markov Chains
 
Review of CausalImpact / Bayesian Structural Time-Series Analysis
Review of CausalImpact / Bayesian Structural Time-Series AnalysisReview of CausalImpact / Bayesian Structural Time-Series Analysis
Review of CausalImpact / Bayesian Structural Time-Series Analysis
 
Tech Talk overview of xgboost and review of paper
Tech Talk overview of xgboost and review of paperTech Talk overview of xgboost and review of paper
Tech Talk overview of xgboost and review of paper
 
Shapley Tech Talk - SHAP and Shapley Discussion
Shapley Tech Talk - SHAP and Shapley DiscussionShapley Tech Talk - SHAP and Shapley Discussion
Shapley Tech Talk - SHAP and Shapley Discussion
 
Hindu ABC Book
Hindu ABC BookHindu ABC Book
Hindu ABC Book
 
Statistical Clustering
Statistical ClusteringStatistical Clustering
Statistical Clustering
 
Variational Inference
Variational InferenceVariational Inference
Variational Inference
 
Time Frequency Analysis for Poets
Time Frequency Analysis for PoetsTime Frequency Analysis for Poets
Time Frequency Analysis for Poets
 
Kalman filter upload
Kalman filter uploadKalman filter upload
Kalman filter upload
 

Recently uploaded

Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptxAneriPatwari
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 

Recently uploaded (20)

Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptx
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 

Bayesian Analysis Fundamentals with Examples

  • 1.
  • 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%
  • 13.
  • 14.
  • 15.
  • 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?
  • 64.
  • 65.
  • 66.
  • 67.
  • 68. Count ways evidence can occur
  • 69. Count ways evidence can occur
  • 70. Count ways evidence can occur
  • 71.
  • 72.
  • 73. Count ways evidence can occur
  • 74.
  • 78.
  • 79.
  • 80.
  • 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
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 106.
  • 107. MCMC
  • 108. MCMC You can evaluate the function, but you cannot draw sample from the function
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 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