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

Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSé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
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
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
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
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
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 

Recently uploaded (20)

Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
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
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
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...
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 

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.