SlideShare a Scribd company logo
1 of 8
Download to read offline
Bayesian Data Analysis
Dr Niamh Cahill (she/her)
Bayes’ Rule
Bayes’ rule
Thomas Bayes’ famous theorem was published in 1763.
For events A and B:
P(A|B) =
P(B|A)P(A)
P(B)
▶ The branch of statistics that you are probably most familiar with up to now
is called frequentist statistics.
▶ Bayesian statistics uses Bayes’ rule for inference and decision making,
frequentist statistics does not.
Toy example
Suppose that you are interested in the probability of rain in the afternoon in your
location.
Let’s assume 30% of days have rain in the afternoon.
(1) P(rain) = 0.3
Let’s assume you have additional information which is that in the morning it’s
cloudy.
Now assume you have an updated probability of rain which is conditional on the
morning being cloudy.
(2) P(rain|cloudy) = 0.6
What information did we need to get from (1) to (2)?
Toy example
We added some information (data) about clouds. We need to know the
probability of observing that data given what we know about rain.
(3) P(cloudy|rain) = 0.8
We also need to know what the marginal probability of being cloudy is.
(4) P(cloudy) = 0.4
Now we can put (1), (3) and (4) together using Bayes’ rule
P(rain|cloudy)
P(A|B)
=
P(cloudy|rain
P(B|A)
)P(rain)
P(A)
P(cloudy)
P(B)
Disease screening example
▶ Suppose there is a test for a disease that has a sensitivity of 80% (i.e., if
100 people that have the disease take the test then 80 of them will get a
positive result).
P(+iv|disease) = 0.8
▶ Suppose the chance of having this disease is 2%.
P(disease) = 0.02
▶ Suppose we also know that the test gives false positive results 5% of the
time (this relates to specificity of the test).
P(+iv|no disease) = 0.05
What is the probability you have the disease given that you receive a positive
test result?
P(disease| + iv) =
P(+ive|disease)P(disease)
P(+ive)
Disease screening example
Find the probability that a person has the disease given they get a positive test
result.
(1) P(+ive|disease)P(disease) = 0.8 × 0.02
(2) P(+ive) =
P(+ive|disease)P(disease) + P(+ive|no disease)P(no disease) = 0.065
P(disease| + iv) =
0.8 × 0.02
0.065
= 0.25
▶ So even with a positive test result for a test with an 80% “hit rate”, the
probability of having the disease is only 25%
▶ The lower probability is a consequence of the low prior probability of the
disease and the non-negligible false positive rate.
Bayes’ rule applied to parameters and data
Given a set of observed data points Y and a set of parameters θ, we write Bayes’
rule as
P(θ|Y )
posterior
=
P(Y |θ)
likelihood
P(θ)
prior
P(Y )
marginal likelihood
Where the denominator is
P(Y ) =
P
θ∗ P(Y |θ∗
)P(θ∗
) for discrete-valued variables, or
P(Y ) =
R
P(Y |θ∗
)P(θ∗
)dθ∗
for continuous variables.
P(Y ) is often difficult to calculate (more on this later) and Baye’s rule is often
written more simply as a proportional statement
P(θ|Y )
posterior
∝ P(Y |θ)
likelihood
P(θ)
prior
Likelihood, Prior & Posterior
P(θ|Y )
posterior
∝ P(Y |θ)
likelihood
P(θ)
prior
▶ P(Y |θ) which is the probability distribution of the data given the
parameters is known as the likelihood
▶ P(θ) which is the probability distribution of the parameters is known as the
prior. The prior represents what we know about the parameters before the
data are observed.
▶ P(θ|Y ) which is the probability distribution of the parameters given the
data is known as the posterior. The posterior represents our updated
knowledge about parameters after the data are observed.

More Related Content

Similar to 1a_Bayes_rule.pdf

Bayesian statistics for biologists and ecologists
Bayesian statistics for biologists and ecologistsBayesian statistics for biologists and ecologists
Bayesian statistics for biologists and ecologistsMasahiro Ryo. Ph.D.
 
Probability concepts-applications-1235015791722176-2
Probability concepts-applications-1235015791722176-2Probability concepts-applications-1235015791722176-2
Probability concepts-applications-1235015791722176-2satysun1990
 
Probability Concepts Applications
Probability Concepts  ApplicationsProbability Concepts  Applications
Probability Concepts Applicationsguest44b78
 
It is assumed that the probability of a success, p, is constant over.pdf
It is assumed that the probability of a success, p, is constant over.pdfIt is assumed that the probability of a success, p, is constant over.pdf
It is assumed that the probability of a success, p, is constant over.pdfshankaranilahuja
 
Introduction to Bayesian Statistics.ppt
Introduction to Bayesian Statistics.pptIntroduction to Bayesian Statistics.ppt
Introduction to Bayesian Statistics.pptLong Dang
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic ReasoningTameem Ahmad
 
2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptxImpanaR2
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical researchBhaswat Chakraborty
 
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...Daniel Katz
 
Chapter 4 part4- General Probability Rules
Chapter 4 part4- General Probability RulesChapter 4 part4- General Probability Rules
Chapter 4 part4- General Probability Rulesnszakir
 
Modeling Social Data, Lecture 6: Classification with Naive Bayes
Modeling Social Data, Lecture 6: Classification with Naive BayesModeling Social Data, Lecture 6: Classification with Naive Bayes
Modeling Social Data, Lecture 6: Classification with Naive Bayesjakehofman
 
Why most published research findings are false
Why most published research findings are falseWhy most published research findings are false
Why most published research findings are falseGilles Guillot
 

Similar to 1a_Bayes_rule.pdf (20)

Bayesian statistics for biologists and ecologists
Bayesian statistics for biologists and ecologistsBayesian statistics for biologists and ecologists
Bayesian statistics for biologists and ecologists
 
Probability concepts-applications-1235015791722176-2
Probability concepts-applications-1235015791722176-2Probability concepts-applications-1235015791722176-2
Probability concepts-applications-1235015791722176-2
 
Probability Concepts Applications
Probability Concepts  ApplicationsProbability Concepts  Applications
Probability Concepts Applications
 
It is assumed that the probability of a success, p, is constant over.pdf
It is assumed that the probability of a success, p, is constant over.pdfIt is assumed that the probability of a success, p, is constant over.pdf
It is assumed that the probability of a success, p, is constant over.pdf
 
Bayesian statistics
Bayesian statisticsBayesian statistics
Bayesian statistics
 
Bayes (1).pptx
Bayes (1).pptxBayes (1).pptx
Bayes (1).pptx
 
Introduction to Bayesian Statistics.ppt
Introduction to Bayesian Statistics.pptIntroduction to Bayesian Statistics.ppt
Introduction to Bayesian Statistics.ppt
 
Lesson 27
Lesson 27Lesson 27
Lesson 27
 
AI Lesson 27
AI Lesson 27AI Lesson 27
AI Lesson 27
 
bayesjaw.ppt
bayesjaw.pptbayesjaw.ppt
bayesjaw.ppt
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic Reasoning
 
2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx2.statistical DEcision makig.pptx
2.statistical DEcision makig.pptx
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical research
 
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...
Quantitative Methods for Lawyers - Class #9 - Bayes Theorem (Part 2), Skewnes...
 
Chapter 4 part4- General Probability Rules
Chapter 4 part4- General Probability RulesChapter 4 part4- General Probability Rules
Chapter 4 part4- General Probability Rules
 
Modeling Social Data, Lecture 6: Classification with Naive Bayes
Modeling Social Data, Lecture 6: Classification with Naive BayesModeling Social Data, Lecture 6: Classification with Naive Bayes
Modeling Social Data, Lecture 6: Classification with Naive Bayes
 
Addition rule and multiplication rule
Addition rule and multiplication rule  Addition rule and multiplication rule
Addition rule and multiplication rule
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Why most published research findings are false
Why most published research findings are falseWhy most published research findings are false
Why most published research findings are false
 
Topics in Probabillity
Topics in ProbabillityTopics in Probabillity
Topics in Probabillity
 

Recently uploaded

Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformationAreesha Ahmad
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learninglevieagacer
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...chandars293
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...ssuser79fe74
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEayushi9330
 
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)Joonhun Lee
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Monika Rani
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...Lokesh Kothari
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts ServiceJustdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Servicemonikaservice1
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 

Recently uploaded (20)

Conjugation, transduction and transformation
Conjugation, transduction and transformationConjugation, transduction and transformation
Conjugation, transduction and transformation
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts ServiceJustdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 

1a_Bayes_rule.pdf

  • 1. Bayesian Data Analysis Dr Niamh Cahill (she/her) Bayes’ Rule
  • 2. Bayes’ rule Thomas Bayes’ famous theorem was published in 1763. For events A and B: P(A|B) = P(B|A)P(A) P(B) ▶ The branch of statistics that you are probably most familiar with up to now is called frequentist statistics. ▶ Bayesian statistics uses Bayes’ rule for inference and decision making, frequentist statistics does not.
  • 3. Toy example Suppose that you are interested in the probability of rain in the afternoon in your location. Let’s assume 30% of days have rain in the afternoon. (1) P(rain) = 0.3 Let’s assume you have additional information which is that in the morning it’s cloudy. Now assume you have an updated probability of rain which is conditional on the morning being cloudy. (2) P(rain|cloudy) = 0.6 What information did we need to get from (1) to (2)?
  • 4. Toy example We added some information (data) about clouds. We need to know the probability of observing that data given what we know about rain. (3) P(cloudy|rain) = 0.8 We also need to know what the marginal probability of being cloudy is. (4) P(cloudy) = 0.4 Now we can put (1), (3) and (4) together using Bayes’ rule P(rain|cloudy) P(A|B) = P(cloudy|rain P(B|A) )P(rain) P(A) P(cloudy) P(B)
  • 5. Disease screening example ▶ Suppose there is a test for a disease that has a sensitivity of 80% (i.e., if 100 people that have the disease take the test then 80 of them will get a positive result). P(+iv|disease) = 0.8 ▶ Suppose the chance of having this disease is 2%. P(disease) = 0.02 ▶ Suppose we also know that the test gives false positive results 5% of the time (this relates to specificity of the test). P(+iv|no disease) = 0.05 What is the probability you have the disease given that you receive a positive test result? P(disease| + iv) = P(+ive|disease)P(disease) P(+ive)
  • 6. Disease screening example Find the probability that a person has the disease given they get a positive test result. (1) P(+ive|disease)P(disease) = 0.8 × 0.02 (2) P(+ive) = P(+ive|disease)P(disease) + P(+ive|no disease)P(no disease) = 0.065 P(disease| + iv) = 0.8 × 0.02 0.065 = 0.25 ▶ So even with a positive test result for a test with an 80% “hit rate”, the probability of having the disease is only 25% ▶ The lower probability is a consequence of the low prior probability of the disease and the non-negligible false positive rate.
  • 7. Bayes’ rule applied to parameters and data Given a set of observed data points Y and a set of parameters θ, we write Bayes’ rule as P(θ|Y ) posterior = P(Y |θ) likelihood P(θ) prior P(Y ) marginal likelihood Where the denominator is P(Y ) = P θ∗ P(Y |θ∗ )P(θ∗ ) for discrete-valued variables, or P(Y ) = R P(Y |θ∗ )P(θ∗ )dθ∗ for continuous variables. P(Y ) is often difficult to calculate (more on this later) and Baye’s rule is often written more simply as a proportional statement P(θ|Y ) posterior ∝ P(Y |θ) likelihood P(θ) prior
  • 8. Likelihood, Prior & Posterior P(θ|Y ) posterior ∝ P(Y |θ) likelihood P(θ) prior ▶ P(Y |θ) which is the probability distribution of the data given the parameters is known as the likelihood ▶ P(θ) which is the probability distribution of the parameters is known as the prior. The prior represents what we know about the parameters before the data are observed. ▶ P(θ|Y ) which is the probability distribution of the parameters given the data is known as the posterior. The posterior represents our updated knowledge about parameters after the data are observed.