SlideShare a Scribd company logo
1 of 10
Bayesian Statistics Tutorial
Urinx
mkk@hust.edu.cn
June 29, 2017
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 1 / 10
Bayesian Statistics Tutorial
Basics
conditional probabilities:
y) :=
p(x|
the joint probalility of x and y:
p(x,y)
p(y)
p(x,y) = p(x|y)p(y) = p(y|x)p(x)
Theorem: Bayes Rule
Denote by X and Y random variables then the following holds
p(y|x) =
p(x|y)p(y)
p(x)
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 2 / 10
Bayesian Statistics Tutorial
An Example
Question
Assume that a patient would like to have such a test carried out on him.
The physician recommends a test which is guaranteed to detect
HIV-positive whenever a patient is infected. On the other hand, for
healthy patients it has a 1% error rate. That is, with probability 0.01 it
diagnoses a patient as HIV-positive even when he is, HIV-negative.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Moreover, assume that 0.15% of the population is infected.
Now the patient has the test carried out and the test returns
HIV-negative. In this case, logic implies that he is healthy, since the test
has 100% detection rate. In the converse case things are not quite as
straightforward.
So what’s the p(X = HIV+|T = HIV+)?
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 3 / 10
Bayesian Statistics Tutorial
An Example
p(t |x)
T = HIV−
X = HIV− X = HIV+
0
T = HIV+
0.99
0.01 1
p(X = HIV+) = 0.0015
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 4 / 10
Bayesian Statistics Tutorial
An Example
By Bayes rule we may write
p(X = HIV+|T = HIV+) =
p(T = HIV+|X = HIV+)p(X = HIV+)
p(T = HIV+)
While weknow all terms in the numerator, p(T = HIV+)itself is
unknown. That said, it can be computed via
p(T = HIV+) =
Σ
p(T = HIV+,x)
x∈{HIV+,HIV−}
Σ
= p(T = HIV+|x)p(x)
x∈{HIV+,HIV−}
= 1.0 · 0.0015 + 0.01 ·0.9985
Substituting back into the conditional expression yields
1.0 ·0.0015
p(X = HIV+|T = HIV+) =
1.0 · 0.0015 + 0.01 ·0.9985
= 0.1306
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 5 / 10
Bayesian Statistics Tutorial
How can we improve the diagnosis
age x
test 1
test 2
Figure: A graphical description of our HIV testing scenario. Knowing the age of
the patient influences our prior on whether the patient is HIV positive (the
random variable X). The outcomes of the tests 1 and 2 are independent of each
other given the status X. We observe the shaded random variables (age, test 1,
test 2) and would like to infer the un-shaded random variable X.
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 6 / 10
Bayesian Statistics Tutorial
How can we improve the diagnosis
Including additional observed random variables
One way is to obtain further information about the patient and to use
this in the diagnosis. For instance, information about his age is quite
useful. Suppose the patient is 35 years old. In this case we would want
to compute p(X = HIV+|T = HIV+,A = 35) where the random variable
A denotes the age.
The corresponding expression yields:
p(T = HIV+|X = HIV+,A)p(X = HIV+|A)
p(T = HIV+|A)
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 7 / 10
Bayesian Statistics Tutorial
How can we improve the diagnosis
We may assume that the test is independent of the age of the patient,
i.e.
p(t |x,a) = p(t |x)
What remains therefore is p(X = HIV+|A). Recent US census data pegs
this number at approximately 0.9%.
p(X = H+|T = H+,A) =
p(T = H+|X = H+,A)p(X = H+|A)
p(T = H+|A)
p(T = H+|X = H+,A)p(X = H+|A)
=
p(T = H+|X = H+,A)p(X = H+|A) + p(T = H+|X = H− ,A)p(X = H
=
p(T = H+|X = H+)p(X = H+|A)
p(T = H+|X = H+)p(X = H+|A) + p(T = H+|X = H− )p(X = H−|A)
=
1 · 0.009
= 0.48
1 ·0.009 + 0.01 ·0.991
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 8 / 10
Bayesian Statistics Tutorial
How can we improve the diagnosis
Multiple measurements
A second tool in our arsenal is the use of multiple measurements. After
the first test the physician is likely to carry out a second test to confirm
the diagnosis. We denote by T1 and T2 (and t1,t2 respectively) the two
tests. Obviously, what we want is that T2 will give us an ”independent”
second opinion of the situation.
What we want is that the diagnosis of T2 is independent of that of T2
given the health status X of the patient. This is expressed as
p(t1,t2|x) = p(t1|x)p(t2|x)
~~~~~~~~~~~~~~~~~~~~~~~~
which are commonly referred to as conditionally independent.
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 9 / 10
Bayesian Statistics Tutorial
How can we improve the diagnosis
we assume that the statistics for T2 are given by
p(t2|x) X = HIV− X = HIV+
T2 = HIV− 0.95
0.05
0.01
0.99
T2 = HIV+
for t1 = t2 = HIV+ we have
p(X = H+|T1 = H+,T2 = H+)
=
p(T1 = H+,T2 = H+|X = H+)p(X = H+|A)
p(T1 = H+,T2 = H+|A)
= p(T1 = H+|X = H+)p(T2 = H+|X = H+)p(X = H+|A) /
p(T1 = H+|X = H+)p(T2 = H+|X = H+)p(X = H+|A)
+ p(T1 = H+|X = H− )p(T2 = H+|X = H− )p(X = H−|A)
=
1 ·0.99 ·0.009
= 0.95
1 ·0.99 ·0.009 + 0.01 ·0.05 · 0.991
Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 10 / 10

More Related Content

Similar to blood_red_demo.pptx

Let X  = (X1,...,Xn) be the blood pressure (measured in .docx
Let X  = (X1,...,Xn) be the blood pressure (measured in .docxLet X  = (X1,...,Xn) be the blood pressure (measured in .docx
Let X  = (X1,...,Xn) be the blood pressure (measured in .docx
washingtonrosy
 
Concepts Of Statistical Inference Statistics.pdf
Concepts Of Statistical Inference Statistics.pdfConcepts Of Statistical Inference Statistics.pdf
Concepts Of Statistical Inference Statistics.pdf
abdiqadiraliadan
 
A New Statistical Aspects of Cancer Diagnosis and Treatment
A New Statistical Aspects of Cancer Diagnosis and TreatmentA New Statistical Aspects of Cancer Diagnosis and Treatment
A New Statistical Aspects of Cancer Diagnosis and Treatment
Junfeng Liu
 
Ebd1 lecture7 2010
Ebd1 lecture7 2010Ebd1 lecture7 2010
Ebd1 lecture7 2010
Reko Kemo
 
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
Université de Liège (ULg)
 
Test of hypothesis (z)
Test of hypothesis (z)Test of hypothesis (z)
Test of hypothesis (z)
Marlon Gomez
 
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
Barbara Osimani
 

Similar to blood_red_demo.pptx (20)

Ch 12 SIGNIFICANT TESTrr.doc
Ch 12 SIGNIFICANT TESTrr.docCh 12 SIGNIFICANT TESTrr.doc
Ch 12 SIGNIFICANT TESTrr.doc
 
Let X  = (X1,...,Xn) be the blood pressure (measured in .docx
Let X  = (X1,...,Xn) be the blood pressure (measured in .docxLet X  = (X1,...,Xn) be the blood pressure (measured in .docx
Let X  = (X1,...,Xn) be the blood pressure (measured in .docx
 
Chi‑square test
Chi‑square test Chi‑square test
Chi‑square test
 
Chi square(hospital admin) A
Chi square(hospital admin) AChi square(hospital admin) A
Chi square(hospital admin) A
 
Concepts Of Statistical Inference Statistics.pdf
Concepts Of Statistical Inference Statistics.pdfConcepts Of Statistical Inference Statistics.pdf
Concepts Of Statistical Inference Statistics.pdf
 
A New Statistical Aspects of Cancer Diagnosis and Treatment
A New Statistical Aspects of Cancer Diagnosis and TreatmentA New Statistical Aspects of Cancer Diagnosis and Treatment
A New Statistical Aspects of Cancer Diagnosis and Treatment
 
slides Testing of hypothesis.pptx
slides Testing  of  hypothesis.pptxslides Testing  of  hypothesis.pptx
slides Testing of hypothesis.pptx
 
Ebd1 lecture7 2010
Ebd1 lecture7 2010Ebd1 lecture7 2010
Ebd1 lecture7 2010
 
Inferential statistics
Inferential statisticsInferential statistics
Inferential statistics
 
inferentialstatistics-210411214248.pdf
inferentialstatistics-210411214248.pdfinferentialstatistics-210411214248.pdf
inferentialstatistics-210411214248.pdf
 
ders 5 hypothesis testing.pptx
ders 5 hypothesis testing.pptxders 5 hypothesis testing.pptx
ders 5 hypothesis testing.pptx
 
TESTS OF SIGNIFICANCE.pptx
TESTS OF SIGNIFICANCE.pptxTESTS OF SIGNIFICANCE.pptx
TESTS OF SIGNIFICANCE.pptx
 
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
Clinical data based optimal STI strategies for HIV: a reinforcement learning ...
 
Test of hypothesis (z)
Test of hypothesis (z)Test of hypothesis (z)
Test of hypothesis (z)
 
Testing of hypothesis
Testing of hypothesisTesting of hypothesis
Testing of hypothesis
 
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
Barbara Osimani, Problems with Evidence of Pharmaceutical Harm. King's Colleg...
 
Lecture # 10 chi-square test of association
Lecture # 10  chi-square test of associationLecture # 10  chi-square test of association
Lecture # 10 chi-square test of association
 
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
 
Hypothesis_testing,regarding software engineering
Hypothesis_testing,regarding software engineeringHypothesis_testing,regarding software engineering
Hypothesis_testing,regarding software engineering
 
UNIT 5.pdf
UNIT 5.pdfUNIT 5.pdf
UNIT 5.pdf
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 

blood_red_demo.pptx

  • 1. Bayesian Statistics Tutorial Urinx mkk@hust.edu.cn June 29, 2017 Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 1 / 10
  • 2. Bayesian Statistics Tutorial Basics conditional probabilities: y) := p(x| the joint probalility of x and y: p(x,y) p(y) p(x,y) = p(x|y)p(y) = p(y|x)p(x) Theorem: Bayes Rule Denote by X and Y random variables then the following holds p(y|x) = p(x|y)p(y) p(x) Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 2 / 10
  • 3. Bayesian Statistics Tutorial An Example Question Assume that a patient would like to have such a test carried out on him. The physician recommends a test which is guaranteed to detect HIV-positive whenever a patient is infected. On the other hand, for healthy patients it has a 1% error rate. That is, with probability 0.01 it diagnoses a patient as HIV-positive even when he is, HIV-negative. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Moreover, assume that 0.15% of the population is infected. Now the patient has the test carried out and the test returns HIV-negative. In this case, logic implies that he is healthy, since the test has 100% detection rate. In the converse case things are not quite as straightforward. So what’s the p(X = HIV+|T = HIV+)? Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 3 / 10
  • 4. Bayesian Statistics Tutorial An Example p(t |x) T = HIV− X = HIV− X = HIV+ 0 T = HIV+ 0.99 0.01 1 p(X = HIV+) = 0.0015 Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 4 / 10
  • 5. Bayesian Statistics Tutorial An Example By Bayes rule we may write p(X = HIV+|T = HIV+) = p(T = HIV+|X = HIV+)p(X = HIV+) p(T = HIV+) While weknow all terms in the numerator, p(T = HIV+)itself is unknown. That said, it can be computed via p(T = HIV+) = Σ p(T = HIV+,x) x∈{HIV+,HIV−} Σ = p(T = HIV+|x)p(x) x∈{HIV+,HIV−} = 1.0 · 0.0015 + 0.01 ·0.9985 Substituting back into the conditional expression yields 1.0 ·0.0015 p(X = HIV+|T = HIV+) = 1.0 · 0.0015 + 0.01 ·0.9985 = 0.1306 Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 5 / 10
  • 6. Bayesian Statistics Tutorial How can we improve the diagnosis age x test 1 test 2 Figure: A graphical description of our HIV testing scenario. Knowing the age of the patient influences our prior on whether the patient is HIV positive (the random variable X). The outcomes of the tests 1 and 2 are independent of each other given the status X. We observe the shaded random variables (age, test 1, test 2) and would like to infer the un-shaded random variable X. Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 6 / 10
  • 7. Bayesian Statistics Tutorial How can we improve the diagnosis Including additional observed random variables One way is to obtain further information about the patient and to use this in the diagnosis. For instance, information about his age is quite useful. Suppose the patient is 35 years old. In this case we would want to compute p(X = HIV+|T = HIV+,A = 35) where the random variable A denotes the age. The corresponding expression yields: p(T = HIV+|X = HIV+,A)p(X = HIV+|A) p(T = HIV+|A) Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 7 / 10
  • 8. Bayesian Statistics Tutorial How can we improve the diagnosis We may assume that the test is independent of the age of the patient, i.e. p(t |x,a) = p(t |x) What remains therefore is p(X = HIV+|A). Recent US census data pegs this number at approximately 0.9%. p(X = H+|T = H+,A) = p(T = H+|X = H+,A)p(X = H+|A) p(T = H+|A) p(T = H+|X = H+,A)p(X = H+|A) = p(T = H+|X = H+,A)p(X = H+|A) + p(T = H+|X = H− ,A)p(X = H = p(T = H+|X = H+)p(X = H+|A) p(T = H+|X = H+)p(X = H+|A) + p(T = H+|X = H− )p(X = H−|A) = 1 · 0.009 = 0.48 1 ·0.009 + 0.01 ·0.991 Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 8 / 10
  • 9. Bayesian Statistics Tutorial How can we improve the diagnosis Multiple measurements A second tool in our arsenal is the use of multiple measurements. After the first test the physician is likely to carry out a second test to confirm the diagnosis. We denote by T1 and T2 (and t1,t2 respectively) the two tests. Obviously, what we want is that T2 will give us an ”independent” second opinion of the situation. What we want is that the diagnosis of T2 is independent of that of T2 given the health status X of the patient. This is expressed as p(t1,t2|x) = p(t1|x)p(t2|x) ~~~~~~~~~~~~~~~~~~~~~~~~ which are commonly referred to as conditionally independent. Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 9 / 10
  • 10. Bayesian Statistics Tutorial How can we improve the diagnosis we assume that the statistics for T2 are given by p(t2|x) X = HIV− X = HIV+ T2 = HIV− 0.95 0.05 0.01 0.99 T2 = HIV+ for t1 = t2 = HIV+ we have p(X = H+|T1 = H+,T2 = H+) = p(T1 = H+,T2 = H+|X = H+)p(X = H+|A) p(T1 = H+,T2 = H+|A) = p(T1 = H+|X = H+)p(T2 = H+|X = H+)p(X = H+|A) / p(T1 = H+|X = H+)p(T2 = H+|X = H+)p(X = H+|A) + p(T1 = H+|X = H− )p(T2 = H+|X = H− )p(X = H−|A) = 1 ·0.99 ·0.009 = 0.95 1 ·0.99 ·0.009 + 0.01 ·0.05 · 0.991 Urinx (HUST) Bayesian Statistics Tutorial June 29, 2017 10 / 10