SlideShare una empresa de Scribd logo
1 de 41
Bayes for Beginners
LUCA CHECH AND JOLANDA MALAMUD
SUPERVISOR: THOMAS PARR
13TH FEBRUARY 2019
Outline
• Probability distributions
• Joint probability
• Marginal probability
• Conditional probability
• Bayes’ theorem
• Bayesian inference
• Coin toss example
“Probability is orderly opinion and
inference from data is nothing other than
the revision of such opinion in the light
of relevant new information.”
Eliezer S. Yudkowsky
Some applications
P(X)
Probability distribution
Discrete Continuous
1
2
100
…
X P(X)
1
2
…
100
1/100
1/100
…
1/100
PMF
1 100
…
1/100
X
P(X)
2
𝑋
𝑃𝑀𝐹 𝑋 = 1
PDF
UK
POPULATION
Height
X
1.8 m 0
1.75 ≤ 𝑋 ≤ 1.85
P given by the area
Probability
• Probability of A occurring: P(A)
• Probability of B occurring: P(B)
• Joint probability (A AND B both occurring): P(A,B)
Marginal probability
x
Y
disease
symptoms
0
0
1
1
x
Y
0.5
0.1
0.1
0.3
disease
symptoms
𝑥,𝑦
𝑃 𝑋 = 𝑥, 𝑌 = 𝑦 = 1
𝑃 𝑌 = 1 = 0.1 + 0.3 = 0.4
𝑃 𝑋 = 0 = 0.1 + 0.5 = 0.6
𝑃 𝑋 = 𝑥 =
𝑦
𝑃(𝑋 = 𝑥, 𝑌 = 𝑦)
joint probability : 𝑃 𝑋 = 0, 𝑌 = 1 = 0.1
Conditional probability
What is the probability of A occurring, given that B has occurred?
Probability of A given B?
0
0
1
1
x
Y
0.5
0.1
0.1
0.3
disease
symptoms
joint probability : 𝑃 𝑋 = 0, 𝑌 = 1 = 0.1
Conditional probability:
𝑃 𝑋 = 1 𝑌 = 1
𝑃 𝑋 = 0 𝑌 = 1
𝑃 𝑋 = 1 𝑌 = 1 = 0.3
𝑃 𝑋 = 0 𝑌 = 1 = 0.1
𝑃 𝑋 = 1 𝑌 = 1 =
0.3
0.1 + 0.3
𝑃 𝑋 = 1 𝑌 = 1 =
0.3
0.1 + 0.3
=
3
4
𝑃 𝑋 = 0 𝑌 = 1 =
0.1
0.1 + 0.3
𝑃 𝑋 = 0 𝑌 = 1 =
0.1
0.1 + 0.3
=
1
4
joint probability : 𝑃 𝑋 = 0, 𝑌 = 1
Conditional Probability
P(X|Y)=
𝑃(𝑋=𝑥,𝑌=𝑦)
𝑃(𝑌=𝑦)
𝑃 𝐶| + =
𝑃(𝐶, +)
𝑃(+)
Conditional probability: Example
𝑃 𝐶 =
1
100
𝑃 𝑁𝐶 =
99
100
𝑃 +|𝐶 =
90
100
𝑃 +|𝑁𝐶 =
8
100
𝑃 𝐶| + = ? ? ?
𝑃 + 𝐶 =
𝑃 + 𝐶 =
𝑃(+, 𝐶)
𝑃(𝐶)
𝑃 𝐶, + = 𝑃(+|𝐶) × 𝑃(𝐶)
𝑃 𝐶, + = 𝑃 + 𝐶 × 𝑃 𝐶 =
90
100
×
1
100
𝑃 𝐶, + = 𝑃 + 𝐶 × 𝑃 𝐶 =
9
1000
𝑃 + =
𝑥
𝑃(𝑋, +)
𝑥
𝑃(𝑋, +) = 𝑃 𝐶, + + 𝑃(𝑁𝐶, +)
𝑃 + 𝑁𝐶 =
𝑃(+, 𝑁𝐶)
𝑃(𝑁𝐶)
𝑃 +, 𝑁𝐶 = 𝑃(+|𝑁𝐶) × 𝑃(𝑁𝐶)
𝑃 +, 𝑁𝐶 = 𝑃 + 𝑁𝐶 × 𝑃 𝑁𝐶 =
8
100
×
99
100
=
792
10000
𝑃 𝐶| + =
𝑃(𝐶, +)
𝑃(+)
=
9
1000
9
1000
+
792
10000
≅ 0.1
Conditional probability: Example
𝑃 𝐶 =
1
100
𝑃 𝑁𝐶 =
99
100
𝑃 +|𝐶 =
90
100
𝑃 +|𝑁𝐶 =
8
100
𝑃 𝐶| + = ? ? ?
Derivation of Bayes’ theorem
𝑃 𝐵 𝐴 =
𝑃(𝐵 ∩ 𝐴)
𝑃(𝐴)
=
𝑃(𝐴 ∩ 𝐵)
𝑃(𝐴)
𝑃 𝐵 𝐴 =
𝑃(𝐵 ∩ 𝐴)
𝑃(𝐴)
𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐵 𝐴 × 𝑃(𝐴)
𝑃 𝐴 𝐵 =
𝑃(𝐴 ∩ 𝐵)
𝑃(𝐵)
𝑃 𝐴 𝐵 =
𝑃(𝐴 ∩ 𝐵)
𝑃(𝐵)
=
𝑃(𝐵|𝐴) × 𝑃(𝐴)
𝑃(𝐵)
𝑃 𝐴 𝐵 =
𝑃(𝐵|𝐴) × 𝑃(𝐴)
𝑃(𝐵)
Bayes’ theorem
1
2
Bayes’ theorem, alternative form
𝑃 𝐴 𝐵 =
𝑃(𝐵|𝐴) × 𝑃(𝐴)
𝑃(𝐵)
Bayes’ theorem problems
Example 1
P(A) = probability of liver disease = 0.10
P(B) = probability of alcoholism = 0.05
P(B|A) = 0.07
P(A|B) = ?
𝑃 𝐴 𝐵 =
𝑃 𝐵 𝐴 ×𝑃 𝐴
𝑃 𝐵
=
0.07 × 0.10
0.05
= 0.14
In other words, if the patient is an alcoholic, their chances of having liver disease is 0.14 (14%)
10% of patients in a clinic have liver disease. Five percent of the clinic’s patients are alcoholics.
Amongst those patients diagnosed with liver disease, 7% are alcoholics. You are interested in knowing
the probability of a patient having liver disease, given that he is an alcoholic.
Example 2
A disease occurs in 0.5% of the population
A diagnostic test gives a positive result in:
◦ 99% of people with the disease
◦ 5% of people without the disease (false positive)
A person receives a positive result
What is the probability of them having the disease, given a positive result?
𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 =
𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 × 𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒
𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡
We know:
𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 = 0.99
𝑃(𝑑𝑖𝑠𝑒𝑎𝑠𝑒) = 0.005
𝑃(𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡) = ???
𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 = 𝑃 𝐷 𝑃𝑇 × 𝑃 𝐷 + 𝑃 𝑃𝑇 ~𝐷 × 𝑃 ~𝐷
= 0.99 × 0.005 + 0.05 × 0.995 = 0.005
Where:
𝑃 𝐷 = chance of having the disease
𝑃 ~𝐷 = chance of not having the disease
Remember: 𝑃 ~𝐷 = 1 − 𝑃 𝐷
𝑃 𝑃𝑇 𝐷 = chance of positive test given that disease is present
𝑃 𝑃𝑇 ~𝐷 = chance of positive test given that the disease isn’t present
Therefore:
𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 = 0.99 × 0.005 = 0.09
𝑖. 𝑒. 9%
Frequentist vs. Bayesian statistics
Frequentist models in practice
• Model: 𝑌 = 𝑋𝜃 + 𝜀
• Data X is random variable, while parameters 𝜽 are unknown but fixed
• We assume there is a true set of parameters, or true model of the world, and we
are concerned with getting the best possible estimate
• We are interested in point estimates of parameters given the data
Bayesian models in practice
• Model: 𝑌 = 𝑋𝜃 + 𝜀
• Data X is fixed, while parameters 𝜃 are considered to be random
variables
• There is no single set of parameters that denotes a true model of the
world - we have parameters that are more or less probable
• We are interested in distribution of parameters given the data
Bayesian Inference
• Provides a dynamic model through which our belief is constantly updated as
we add more data
• Ultimate goal is to calculate the posterior probability density, which is
proportional to the likelihood (of our data being correct) and our prior
knowledge
• Can be used as model for the brain (Bayesian brain), history and human
behaviour
Bayes rule
Likelihood
• How good are our parameters given the data
• Prior knowledge is incorporated and used to update our beliefs about the
parameters
𝑃 𝜃 𝐷 =
𝑃 𝐷 𝜃 × 𝑃 𝜃
𝑃 𝐷
∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃
Prior
Posterior
Evidence 𝑃 𝐷 𝜃 × 𝑃 𝜃 𝑑𝜃
Generative models
• Specify a joint probability distribution over all variables (observations and
parameters)  requires a likelihood function and a prior:
𝑃 𝐷, 𝜃 𝑚 = 𝑃 𝐷 𝜃, 𝑚 × 𝑃 𝜃 𝑚 ∝ 𝑃 𝜃 𝐷, 𝑚
• Model comparison based on the model evidence:
𝑃 𝐷 𝑚 = 𝑃 𝐷 𝜃, 𝑚 × 𝑃 𝜃 𝑚 𝑑𝜃
Principles of Bayesian Inference
• Formulation of a generative model
• Observation of data
• Model inversion – updating one’s belief
Model
Measurement
𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃(𝜃)
data D
Likelihood function 𝑃 𝐷 𝜃
Prior distribution 𝑃(𝜃)
Posterior distribution
Model evidence
Priors
Priors can be of different sorts, e.g.
• empirical (previous data)
• uninformed
• principled (e.g. positivity constraints)
• shrinkage
Conjugate priors = posterior 𝑃 𝐷 𝜃 is in the same family as the prior 𝑃 𝜃
• effect of more
informative prior
distributions on
the posterior
distribution
𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃
∝ 𝑙𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑝𝑟𝑖𝑜𝑟
𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃
∝ 𝑙𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑝𝑟𝑖𝑜𝑟
• effect of larger
sample sizes on
the posterior
distribution
Example: Coin flipping model
• Someone flips a coin
• We don’t know if the coin is fair or not
• We are told only the outcome of the coin flipping
• 1st Hypothesis: Coin is fair, 50% Heads or Tails
• 2nd Hypothesis: Both sides of the coin are heads, 100% Heads
Example: Coin flipping model
Example: Coin flipping model
• 1st Hypothesis: Coin is fair, 50% Heads or Tails
𝑃 𝐴 = 𝑓𝑎𝑖𝑟 𝑐𝑜𝑖𝑛 = 0.99
• 2nd Hypothesis: Both sides of the coin are heads, 100% Heads
𝑃 𝐴 = 𝑢𝑛𝑓𝑎𝑖𝑟 𝑐𝑜𝑖𝑛 = 0.01
•
Example: Coin flipping model
•
Example: Coin flipping model
Coin is flipped a second time and it is heads again
 Posterior in the previous time step becomes the new prior!!
Example: Coin flipping model
Example: Coin flipping model
Hypothesis testing
Classical
• Define the null hypothesis
• H0: Coin is fair θ=0.5
•
Bayesian Inference
• Define a hypothesis
• H: θ>0.1
0.1
Example: Coin flipping model
𝐷 = 𝑇 𝐻 𝑇 𝐻 𝑇 𝑇 𝑇 𝑇 𝑇 𝑇 and we think a priori that the coin is fair:
𝑃 𝑓𝑎𝑖𝑟 = 0.8, 𝑃 𝑏𝑒𝑛𝑡 = 0.2
Evidence for a fair model is:
𝑃 𝐷 𝑓𝑎𝑖𝑟 = 0.510 ≈ 0.001
And for a bent model:
𝑃 𝐷 𝑏𝑒𝑛𝑡 = 𝑃 𝑏𝑒𝑛𝑡 𝜃, 𝐷 × 𝑃 𝜃 𝑏𝑒𝑛𝑡 𝑑𝜃
= 𝜃2 × (1 − 𝜃)8𝑑𝜃 = 𝐵(3,9) ≈ 0.002
Posterior for the models:
𝑃 𝑓𝑎𝑖𝑟 𝐷 ∝ 0.001 × 0.8 = 0.0008
𝑃 𝑏𝑒𝑛𝑡 𝐷 ∝ 0.002 × 0.2 = 0.0004
"A Bayesian is one who,
vaguely expecting a horse,
and catching a glimpse of a donkey,
strongly believes he has seen a mule."
References
• Previous MfD slides
• Bayesian statistics (a very brief introduction) – Ken Rice
• http://www.statisticshowto.com/bayes-theorem-problems/
• Slides “Bayesian inference and generative models” of K.E. Stephan
• Introslides to probabilistic & unsupervised learning of M. Sahani
• Animations: https://blog.stata.com/2016/11/01/introduction-to-
bayesian-statistics-part-1-the-basic-concepts/

Más contenido relacionado

Similar a Bayes for Beginners: A Concise Introduction to Bayesian Statistics

Basic statistics for algorithmic trading
Basic statistics for algorithmic tradingBasic statistics for algorithmic trading
Basic statistics for algorithmic tradingQuantInsti
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical researchBhaswat Chakraborty
 
Probability Distributions.pdf
Probability Distributions.pdfProbability Distributions.pdf
Probability Distributions.pdfShivakumar B N
 
Introduction to probabilities and radom variables
Introduction to probabilities and radom variablesIntroduction to probabilities and radom variables
Introduction to probabilities and radom variablesmohammedderriche2
 
Discrete and continuous probability distributions ppt @ bec doms
Discrete and continuous probability distributions ppt @ bec domsDiscrete and continuous probability distributions ppt @ bec doms
Discrete and continuous probability distributions ppt @ bec domsBabasab Patil
 
STSTISTICS AND PROBABILITY THEORY .pptx
STSTISTICS AND PROBABILITY THEORY  .pptxSTSTISTICS AND PROBABILITY THEORY  .pptx
STSTISTICS AND PROBABILITY THEORY .pptxVenuKumar65
 
8. Hypothesis Testing.ppt
8. Hypothesis Testing.ppt8. Hypothesis Testing.ppt
8. Hypothesis Testing.pptABDULRAUF411
 
hypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity universityhypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity universitydeepti .
 
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxCHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxanshujain54751
 

Similar a Bayes for Beginners: A Concise Introduction to Bayesian Statistics (20)

Probability
ProbabilityProbability
Probability
 
Basic statistics for algorithmic trading
Basic statistics for algorithmic tradingBasic statistics for algorithmic trading
Basic statistics for algorithmic trading
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical research
 
Probability Distributions.pdf
Probability Distributions.pdfProbability Distributions.pdf
Probability Distributions.pdf
 
05inference_2011.ppt
05inference_2011.ppt05inference_2011.ppt
05inference_2011.ppt
 
Discrete and Continuous Random Variables
Discrete and Continuous Random VariablesDiscrete and Continuous Random Variables
Discrete and Continuous Random Variables
 
U unit8 ksb
U unit8 ksbU unit8 ksb
U unit8 ksb
 
Introduction to probabilities and radom variables
Introduction to probabilities and radom variablesIntroduction to probabilities and radom variables
Introduction to probabilities and radom variables
 
Discrete and continuous probability distributions ppt @ bec doms
Discrete and continuous probability distributions ppt @ bec domsDiscrete and continuous probability distributions ppt @ bec doms
Discrete and continuous probability distributions ppt @ bec doms
 
STSTISTICS AND PROBABILITY THEORY .pptx
STSTISTICS AND PROBABILITY THEORY  .pptxSTSTISTICS AND PROBABILITY THEORY  .pptx
STSTISTICS AND PROBABILITY THEORY .pptx
 
8. Hypothesis Testing.ppt
8. Hypothesis Testing.ppt8. Hypothesis Testing.ppt
8. Hypothesis Testing.ppt
 
Binomial probability distributions
Binomial probability distributions  Binomial probability distributions
Binomial probability distributions
 
hypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity universityhypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity university
 
Bayesian Statistics.pdf
Bayesian Statistics.pdfBayesian Statistics.pdf
Bayesian Statistics.pdf
 
Machine learning session2
Machine learning   session2Machine learning   session2
Machine learning session2
 
Gerstman_PP09.ppt
Gerstman_PP09.pptGerstman_PP09.ppt
Gerstman_PP09.ppt
 
Gerstman_PP09.ppt
Gerstman_PP09.pptGerstman_PP09.ppt
Gerstman_PP09.ppt
 
Ppt1
Ppt1Ppt1
Ppt1
 
Phylogenetics2
Phylogenetics2Phylogenetics2
Phylogenetics2
 
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptxCHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
CHAPTER 1 THEORY OF PROBABILITY AND STATISTICS.pptx
 

Más de KhushiDuttVatsa

processing and marketing.pptx
processing and marketing.pptxprocessing and marketing.pptx
processing and marketing.pptxKhushiDuttVatsa
 
Unit 2 Star Activity.pdf
Unit 2 Star Activity.pdfUnit 2 Star Activity.pdf
Unit 2 Star Activity.pdfKhushiDuttVatsa
 
Unit 3 Gene Transfer Techniques.pdf
Unit 3 Gene Transfer Techniques.pdfUnit 3 Gene Transfer Techniques.pdf
Unit 3 Gene Transfer Techniques.pdfKhushiDuttVatsa
 
Southern-blotting-and-Western-blotting.pptx
Southern-blotting-and-Western-blotting.pptxSouthern-blotting-and-Western-blotting.pptx
Southern-blotting-and-Western-blotting.pptxKhushiDuttVatsa
 

Más de KhushiDuttVatsa (7)

processing and marketing.pptx
processing and marketing.pptxprocessing and marketing.pptx
processing and marketing.pptx
 
Unit 2 Star Activity.pdf
Unit 2 Star Activity.pdfUnit 2 Star Activity.pdf
Unit 2 Star Activity.pdf
 
Unit 3 Gene Transfer Techniques.pdf
Unit 3 Gene Transfer Techniques.pdfUnit 3 Gene Transfer Techniques.pdf
Unit 3 Gene Transfer Techniques.pdf
 
Unit 2 Gene Cloning.pdf
Unit 2 Gene Cloning.pdfUnit 2 Gene Cloning.pdf
Unit 2 Gene Cloning.pdf
 
Southern-blotting-and-Western-blotting.pptx
Southern-blotting-and-Western-blotting.pptxSouthern-blotting-and-Western-blotting.pptx
Southern-blotting-and-Western-blotting.pptx
 
bayesNaive.ppt
bayesNaive.pptbayesNaive.ppt
bayesNaive.ppt
 
Bayes_Theorem.ppt
Bayes_Theorem.pptBayes_Theorem.ppt
Bayes_Theorem.ppt
 

Último

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 

Último (20)

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 

Bayes for Beginners: A Concise Introduction to Bayesian Statistics

  • 1. Bayes for Beginners LUCA CHECH AND JOLANDA MALAMUD SUPERVISOR: THOMAS PARR 13TH FEBRUARY 2019
  • 2. Outline • Probability distributions • Joint probability • Marginal probability • Conditional probability • Bayes’ theorem • Bayesian inference • Coin toss example
  • 3. “Probability is orderly opinion and inference from data is nothing other than the revision of such opinion in the light of relevant new information.” Eliezer S. Yudkowsky
  • 5. P(X) Probability distribution Discrete Continuous 1 2 100 … X P(X) 1 2 … 100 1/100 1/100 … 1/100 PMF 1 100 … 1/100 X P(X) 2 𝑋 𝑃𝑀𝐹 𝑋 = 1 PDF UK POPULATION Height X 1.8 m 0 1.75 ≤ 𝑋 ≤ 1.85 P given by the area
  • 6. Probability • Probability of A occurring: P(A) • Probability of B occurring: P(B) • Joint probability (A AND B both occurring): P(A,B)
  • 7.
  • 8. Marginal probability x Y disease symptoms 0 0 1 1 x Y 0.5 0.1 0.1 0.3 disease symptoms 𝑥,𝑦 𝑃 𝑋 = 𝑥, 𝑌 = 𝑦 = 1 𝑃 𝑌 = 1 = 0.1 + 0.3 = 0.4 𝑃 𝑋 = 0 = 0.1 + 0.5 = 0.6 𝑃 𝑋 = 𝑥 = 𝑦 𝑃(𝑋 = 𝑥, 𝑌 = 𝑦) joint probability : 𝑃 𝑋 = 0, 𝑌 = 1 = 0.1
  • 9. Conditional probability What is the probability of A occurring, given that B has occurred? Probability of A given B?
  • 10. 0 0 1 1 x Y 0.5 0.1 0.1 0.3 disease symptoms joint probability : 𝑃 𝑋 = 0, 𝑌 = 1 = 0.1 Conditional probability: 𝑃 𝑋 = 1 𝑌 = 1 𝑃 𝑋 = 0 𝑌 = 1 𝑃 𝑋 = 1 𝑌 = 1 = 0.3 𝑃 𝑋 = 0 𝑌 = 1 = 0.1 𝑃 𝑋 = 1 𝑌 = 1 = 0.3 0.1 + 0.3 𝑃 𝑋 = 1 𝑌 = 1 = 0.3 0.1 + 0.3 = 3 4 𝑃 𝑋 = 0 𝑌 = 1 = 0.1 0.1 + 0.3 𝑃 𝑋 = 0 𝑌 = 1 = 0.1 0.1 + 0.3 = 1 4 joint probability : 𝑃 𝑋 = 0, 𝑌 = 1 Conditional Probability P(X|Y)= 𝑃(𝑋=𝑥,𝑌=𝑦) 𝑃(𝑌=𝑦)
  • 11. 𝑃 𝐶| + = 𝑃(𝐶, +) 𝑃(+) Conditional probability: Example 𝑃 𝐶 = 1 100 𝑃 𝑁𝐶 = 99 100 𝑃 +|𝐶 = 90 100 𝑃 +|𝑁𝐶 = 8 100 𝑃 𝐶| + = ? ? ? 𝑃 + 𝐶 = 𝑃 + 𝐶 = 𝑃(+, 𝐶) 𝑃(𝐶) 𝑃 𝐶, + = 𝑃(+|𝐶) × 𝑃(𝐶) 𝑃 𝐶, + = 𝑃 + 𝐶 × 𝑃 𝐶 = 90 100 × 1 100 𝑃 𝐶, + = 𝑃 + 𝐶 × 𝑃 𝐶 = 9 1000 𝑃 + = 𝑥 𝑃(𝑋, +) 𝑥 𝑃(𝑋, +) = 𝑃 𝐶, + + 𝑃(𝑁𝐶, +) 𝑃 + 𝑁𝐶 = 𝑃(+, 𝑁𝐶) 𝑃(𝑁𝐶) 𝑃 +, 𝑁𝐶 = 𝑃(+|𝑁𝐶) × 𝑃(𝑁𝐶) 𝑃 +, 𝑁𝐶 = 𝑃 + 𝑁𝐶 × 𝑃 𝑁𝐶 = 8 100 × 99 100 = 792 10000
  • 12. 𝑃 𝐶| + = 𝑃(𝐶, +) 𝑃(+) = 9 1000 9 1000 + 792 10000 ≅ 0.1 Conditional probability: Example 𝑃 𝐶 = 1 100 𝑃 𝑁𝐶 = 99 100 𝑃 +|𝐶 = 90 100 𝑃 +|𝑁𝐶 = 8 100 𝑃 𝐶| + = ? ? ?
  • 13. Derivation of Bayes’ theorem 𝑃 𝐵 𝐴 = 𝑃(𝐵 ∩ 𝐴) 𝑃(𝐴) = 𝑃(𝐴 ∩ 𝐵) 𝑃(𝐴) 𝑃 𝐵 𝐴 = 𝑃(𝐵 ∩ 𝐴) 𝑃(𝐴) 𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐵 𝐴 × 𝑃(𝐴) 𝑃 𝐴 𝐵 = 𝑃(𝐴 ∩ 𝐵) 𝑃(𝐵) 𝑃 𝐴 𝐵 = 𝑃(𝐴 ∩ 𝐵) 𝑃(𝐵) = 𝑃(𝐵|𝐴) × 𝑃(𝐴) 𝑃(𝐵) 𝑃 𝐴 𝐵 = 𝑃(𝐵|𝐴) × 𝑃(𝐴) 𝑃(𝐵) Bayes’ theorem 1 2
  • 14. Bayes’ theorem, alternative form 𝑃 𝐴 𝐵 = 𝑃(𝐵|𝐴) × 𝑃(𝐴) 𝑃(𝐵)
  • 16. Example 1 P(A) = probability of liver disease = 0.10 P(B) = probability of alcoholism = 0.05 P(B|A) = 0.07 P(A|B) = ? 𝑃 𝐴 𝐵 = 𝑃 𝐵 𝐴 ×𝑃 𝐴 𝑃 𝐵 = 0.07 × 0.10 0.05 = 0.14 In other words, if the patient is an alcoholic, their chances of having liver disease is 0.14 (14%) 10% of patients in a clinic have liver disease. Five percent of the clinic’s patients are alcoholics. Amongst those patients diagnosed with liver disease, 7% are alcoholics. You are interested in knowing the probability of a patient having liver disease, given that he is an alcoholic.
  • 17. Example 2 A disease occurs in 0.5% of the population A diagnostic test gives a positive result in: ◦ 99% of people with the disease ◦ 5% of people without the disease (false positive) A person receives a positive result What is the probability of them having the disease, given a positive result?
  • 18. 𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 = 𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 × 𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 We know: 𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 = 0.99 𝑃(𝑑𝑖𝑠𝑒𝑎𝑠𝑒) = 0.005 𝑃(𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡) = ???
  • 19. 𝑃 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 = 𝑃 𝐷 𝑃𝑇 × 𝑃 𝐷 + 𝑃 𝑃𝑇 ~𝐷 × 𝑃 ~𝐷 = 0.99 × 0.005 + 0.05 × 0.995 = 0.005 Where: 𝑃 𝐷 = chance of having the disease 𝑃 ~𝐷 = chance of not having the disease Remember: 𝑃 ~𝐷 = 1 − 𝑃 𝐷 𝑃 𝑃𝑇 𝐷 = chance of positive test given that disease is present 𝑃 𝑃𝑇 ~𝐷 = chance of positive test given that the disease isn’t present
  • 20. Therefore: 𝑃 𝑑𝑖𝑠𝑒𝑎𝑠𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑡𝑒𝑠𝑡 = 0.99 × 0.005 = 0.09 𝑖. 𝑒. 9%
  • 22. Frequentist models in practice • Model: 𝑌 = 𝑋𝜃 + 𝜀 • Data X is random variable, while parameters 𝜽 are unknown but fixed • We assume there is a true set of parameters, or true model of the world, and we are concerned with getting the best possible estimate • We are interested in point estimates of parameters given the data
  • 23. Bayesian models in practice • Model: 𝑌 = 𝑋𝜃 + 𝜀 • Data X is fixed, while parameters 𝜃 are considered to be random variables • There is no single set of parameters that denotes a true model of the world - we have parameters that are more or less probable • We are interested in distribution of parameters given the data
  • 24. Bayesian Inference • Provides a dynamic model through which our belief is constantly updated as we add more data • Ultimate goal is to calculate the posterior probability density, which is proportional to the likelihood (of our data being correct) and our prior knowledge • Can be used as model for the brain (Bayesian brain), history and human behaviour
  • 25. Bayes rule Likelihood • How good are our parameters given the data • Prior knowledge is incorporated and used to update our beliefs about the parameters 𝑃 𝜃 𝐷 = 𝑃 𝐷 𝜃 × 𝑃 𝜃 𝑃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃 Prior Posterior Evidence 𝑃 𝐷 𝜃 × 𝑃 𝜃 𝑑𝜃
  • 26. Generative models • Specify a joint probability distribution over all variables (observations and parameters)  requires a likelihood function and a prior: 𝑃 𝐷, 𝜃 𝑚 = 𝑃 𝐷 𝜃, 𝑚 × 𝑃 𝜃 𝑚 ∝ 𝑃 𝜃 𝐷, 𝑚 • Model comparison based on the model evidence: 𝑃 𝐷 𝑚 = 𝑃 𝐷 𝜃, 𝑚 × 𝑃 𝜃 𝑚 𝑑𝜃
  • 27. Principles of Bayesian Inference • Formulation of a generative model • Observation of data • Model inversion – updating one’s belief Model Measurement 𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃(𝜃) data D Likelihood function 𝑃 𝐷 𝜃 Prior distribution 𝑃(𝜃) Posterior distribution Model evidence
  • 28. Priors Priors can be of different sorts, e.g. • empirical (previous data) • uninformed • principled (e.g. positivity constraints) • shrinkage Conjugate priors = posterior 𝑃 𝐷 𝜃 is in the same family as the prior 𝑃 𝜃
  • 29. • effect of more informative prior distributions on the posterior distribution 𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃 ∝ 𝑙𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑝𝑟𝑖𝑜𝑟
  • 30. 𝑃 𝜃 𝐷 ∝ 𝑃 𝐷 𝜃 × 𝑃 𝜃 ∝ 𝑙𝑖𝑘𝑒𝑙𝑖ℎ𝑜𝑜𝑑 × 𝑝𝑟𝑖𝑜𝑟 • effect of larger sample sizes on the posterior distribution
  • 31. Example: Coin flipping model • Someone flips a coin • We don’t know if the coin is fair or not • We are told only the outcome of the coin flipping
  • 32. • 1st Hypothesis: Coin is fair, 50% Heads or Tails • 2nd Hypothesis: Both sides of the coin are heads, 100% Heads Example: Coin flipping model
  • 33. Example: Coin flipping model • 1st Hypothesis: Coin is fair, 50% Heads or Tails 𝑃 𝐴 = 𝑓𝑎𝑖𝑟 𝑐𝑜𝑖𝑛 = 0.99 • 2nd Hypothesis: Both sides of the coin are heads, 100% Heads 𝑃 𝐴 = 𝑢𝑛𝑓𝑎𝑖𝑟 𝑐𝑜𝑖𝑛 = 0.01
  • 36. Coin is flipped a second time and it is heads again  Posterior in the previous time step becomes the new prior!! Example: Coin flipping model
  • 38. Hypothesis testing Classical • Define the null hypothesis • H0: Coin is fair θ=0.5 • Bayesian Inference • Define a hypothesis • H: θ>0.1 0.1
  • 39. Example: Coin flipping model 𝐷 = 𝑇 𝐻 𝑇 𝐻 𝑇 𝑇 𝑇 𝑇 𝑇 𝑇 and we think a priori that the coin is fair: 𝑃 𝑓𝑎𝑖𝑟 = 0.8, 𝑃 𝑏𝑒𝑛𝑡 = 0.2 Evidence for a fair model is: 𝑃 𝐷 𝑓𝑎𝑖𝑟 = 0.510 ≈ 0.001 And for a bent model: 𝑃 𝐷 𝑏𝑒𝑛𝑡 = 𝑃 𝑏𝑒𝑛𝑡 𝜃, 𝐷 × 𝑃 𝜃 𝑏𝑒𝑛𝑡 𝑑𝜃 = 𝜃2 × (1 − 𝜃)8𝑑𝜃 = 𝐵(3,9) ≈ 0.002 Posterior for the models: 𝑃 𝑓𝑎𝑖𝑟 𝐷 ∝ 0.001 × 0.8 = 0.0008 𝑃 𝑏𝑒𝑛𝑡 𝐷 ∝ 0.002 × 0.2 = 0.0004
  • 40. "A Bayesian is one who, vaguely expecting a horse, and catching a glimpse of a donkey, strongly believes he has seen a mule."
  • 41. References • Previous MfD slides • Bayesian statistics (a very brief introduction) – Ken Rice • http://www.statisticshowto.com/bayes-theorem-problems/ • Slides “Bayesian inference and generative models” of K.E. Stephan • Introslides to probabilistic & unsupervised learning of M. Sahani • Animations: https://blog.stata.com/2016/11/01/introduction-to- bayesian-statistics-part-1-the-basic-concepts/

Notas del editor

  1. 6
  2. 9
  3. 17
  4. 18
  5. 19
  6. 20
  7. 22
  8. 23
  9. 25