SlideShare a Scribd company logo
1 of 15
Download to read offline
Bayesian
Inference
Analysis
Three students are constructing their prior belief
about π, the proportion of Hamilton residents
who support building a casino in Hamilton.
Prior distributions
Anna
prior mean is 0.2
prior standard
deviation is 0.08
beta
distribution(a, b)
Bart
Uniform Prior
p(π) = 1
for 0 <= π <=1.
Beta distribution
a = b = 1
Chris
Trapezoidal shape
continuous prior
Compute Anna's prior distribution (beta
distribution) and equivalent sample size.
• Mean = π̥ = 0.2 σ̥ = Standard deviation = 0.8
π̥=
𝑎𝑎
(𝑎𝑎+𝑏𝑏)
0.2 =
𝑎𝑎
(𝑎𝑎+𝑏𝑏)
b = 4a
σ̥=
̥
π 1− ̥
π
𝑎𝑎+𝑏𝑏+1
0.082
=
0.2 1− 0.2
𝑎𝑎+𝑏𝑏+1
0.0064 =
0.16
(5𝑎𝑎+1)
𝑏𝑏 = 4𝑎𝑎
a = 4.8
b= 19.2
�
𝑒𝑒𝑒𝑒
= 𝑎𝑎 + 𝑏𝑏 + 1
= 4.8 +19.2 +1
= 25
Prior Distribution  Beta distribution (a = 4.8 , b = 19.2)
Bart's prior distribution (beta distribution) and
equivalent sample size.
• uniform prior : a = b = 1
• Equivalent sample size is  a + b + 1 = 3
Prior Distribution  Beta distribution (a = 1 , b = 1)
Chris's prior probability - Trapezoidal shape.
Area=(0.5*2*0.1)+(2*0.2)+(0.5*2*0.2)=0.6 ≠ 1
Find g(π).
• 0 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟏𝟏 𝟎𝟎. 𝟏𝟏 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟑𝟑 𝟎𝟎. 𝟑𝟑 ≤ 𝝅𝝅 ≤ 𝟎𝟎. 𝟓𝟓
• Y = m X + C Y = m X + C Y = m X + C
• 1.0=m * 0.05 + 0 2 = 0*X + C 1.0 = 0.4 *(-2.0/0.2) + C
• m=20 C=2 C=5
• Y=20𝝅𝝅 Y=2 Y= 5-10 𝝅𝝅
g (𝛑𝛑 ) = �
𝟐𝟐𝟐𝟐𝟐𝟐 ; 𝟎𝟎 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟏𝟏
𝟐𝟐 ; 𝟎𝟎. 𝟏𝟏 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟑𝟑
𝟓𝟓 − 𝟏𝟏𝟏𝟏 𝛑𝛑 ; 𝟎𝟎. 𝟑𝟑 ≤ 𝝅𝝅 ≤ 𝟎𝟎. 𝟓𝟓
Is g(π) a proper density? Does it have to be
proper prior to find the posterior distribution.
• To check if g(π) is a proper density, we need to ensure that its
integral over the entire real line is equal to 1.
• In this case, the integral can be calculated by summing the areas of
the trapezoids.
• Area=(0.5*2*0.1)+(2*0.2)+(0.5*2*0.2)=0.6 ≠ 1
• Area of the above graph is not equal to 1.
• However; this is not a problem since the relative weights given by
the shape of the distribution are all that is needed since the
constant will cancel out.
So, g (𝛑𝛑 ) is not a proper density.
Posterior Distribution of all three students
• The posterior distribution for each student can be obtained using
Bayes' theorem,
• y = 26 successes out of n = 100 trials
For Anna, (a = 4.8, b= 19.2)
• PosteriorAnna ∝ Beta(y+a ,(n-y)+b)
• P( 𝛑𝛑| 𝐲𝐲) α P(𝛑𝛑) x P(Y| 𝛑𝛑)
• P( 𝛑𝛑| 𝐲𝐲) α {(𝛑𝛑𝟒𝟒.𝟖𝟖−𝟏𝟏 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏.𝟐𝟐−𝟏𝟏) x (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐)}
• P( 𝛑𝛑| 𝐲𝐲) α Beta(a=30.8, b=93.2)
Posterior ∝ Likelihood × Prior
• for Bart,
• PosteriorBart ∝ Beta(y+a ,(n-y)+b)
• P( 𝛑𝛑| 𝐲𝐲) α P(𝛑𝛑) x P(Y| 𝛑𝛑)
• P( 𝛑𝛑| 𝐲𝐲) α {(𝛑𝛑𝟏𝟏−𝟏𝟏
(𝟏𝟏 − 𝛑𝛑)𝟏𝟏−𝟏𝟏
) x (𝛑𝛑𝟐𝟐𝟐𝟐
(𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐
)}
• P( 𝛑𝛑| 𝐲𝐲) α Beta(a=27, b=75)
Now, we need to integrate
this unnormalized posterior
over the entire parameter
space (0 to 0.5) to normalize
it. This is a numerical
integration task that typically
requires the use of
specialized software or
programming libraries.
• For Chris,
• PosteriorChris​ ∝ Trapezoidal(g(π))
1.For 0≤ 𝛑𝛑 ≤0.1:
Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐) ×(20𝛑𝛑)
2.For 0.1≤ 𝛑𝛑 ≤0.3:
Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐) × (2)
3.For 0.3≤ 𝛑𝛑 ≤0.5:
Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐
(𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐
) ×(5−10 𝛑𝛑)
Normalized Posterior(π ∣y)=
Posterior(π ∣y)
�
0
1
2 Posterior(π ∣y) 𝑑𝑑π
Plots of prior
distributions and
posterior
distributions
• We see that the three
students end up with very
similar posteriors, despite
starting with priors having
quite 3 different shapes.
Plots of prior
distributions
and posterior
distribution
using software
R.
Plots of prior distributions and posterior
distribution using software R.
Conclusion
• Anna thinks that the prior distribution is the beta distribution.
• But Bart doesn't know the local feeling about casinos, so he uses a
uniform distribution.
• And Chris thinks it's a Trapezoidal distribution.
• So prior distributions are different.
• But the posterior distributions, are same for all three.
The plot helps visualize how different prior beliefs influence the update
process in Bayesian inference.
References
•intro-bayesian-statistics.pdf –
https://thenigerianprofessionalaccountant.files.wordpre
ss.com/2013/04/intro-bayesian-statistics.pdf
• https://en.wikipedia.org/wiki/Trapezoidal_distribution

More Related Content

Similar to Bayesian Inference Analysis using R Programming

IIT JAM Math 2022 Question Paper | Sourav Sir's Classes
IIT JAM Math 2022 Question Paper | Sourav Sir's ClassesIIT JAM Math 2022 Question Paper | Sourav Sir's Classes
IIT JAM Math 2022 Question Paper | Sourav Sir's ClassesSOURAV DAS
 
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdf
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdff00a5f08-14cf-4f73-a749-f8e30a016fa4.pdf
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdfSRSstatusking
 
Bisection theorem proof and convergence analysis
Bisection theorem proof and convergence analysisBisection theorem proof and convergence analysis
Bisection theorem proof and convergence analysisHamza Nawaz
 
random forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimationrandom forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimationChristian Robert
 
ABC short course: survey chapter
ABC short course: survey chapterABC short course: survey chapter
ABC short course: survey chapterChristian Robert
 
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...Luca Vitale
 
Quadratic And Roots
Quadratic And RootsQuadratic And Roots
Quadratic And RootsPeking
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manualnmahi96
 
cps170_bayes_nets.ppt
cps170_bayes_nets.pptcps170_bayes_nets.ppt
cps170_bayes_nets.pptFaizAbaas
 
Asymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceAsymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceChristian Robert
 
Workshop on Bayesian Inference for Latent Gaussian Models with Applications
Workshop on Bayesian Inference for Latent Gaussian Models with ApplicationsWorkshop on Bayesian Inference for Latent Gaussian Models with Applications
Workshop on Bayesian Inference for Latent Gaussian Models with ApplicationsChristian Robert
 
baysian in machine learning in Supervised Learning .pptx
baysian in machine learning in Supervised Learning .pptxbaysian in machine learning in Supervised Learning .pptx
baysian in machine learning in Supervised Learning .pptxObsiElias
 
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...RhiannonBanksss
 
maths_formula_sheet.pdf
maths_formula_sheet.pdfmaths_formula_sheet.pdf
maths_formula_sheet.pdfVanhoaTran2
 

Similar to Bayesian Inference Analysis using R Programming (20)

IIT JAM Math 2022 Question Paper | Sourav Sir's Classes
IIT JAM Math 2022 Question Paper | Sourav Sir's ClassesIIT JAM Math 2022 Question Paper | Sourav Sir's Classes
IIT JAM Math 2022 Question Paper | Sourav Sir's Classes
 
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdf
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdff00a5f08-14cf-4f73-a749-f8e30a016fa4.pdf
f00a5f08-14cf-4f73-a749-f8e30a016fa4.pdf
 
Bisection theorem proof and convergence analysis
Bisection theorem proof and convergence analysisBisection theorem proof and convergence analysis
Bisection theorem proof and convergence analysis
 
random forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimationrandom forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimation
 
ABC short course: survey chapter
ABC short course: survey chapterABC short course: survey chapter
ABC short course: survey chapter
 
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...
Estimation of the Latent Signals for Consensus Across Multiple Ranked Lists u...
 
Lec05.pptx
Lec05.pptxLec05.pptx
Lec05.pptx
 
ABC-Gibbs
ABC-GibbsABC-Gibbs
ABC-Gibbs
 
Quadratic And Roots
Quadratic And RootsQuadratic And Roots
Quadratic And Roots
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manual
 
cps170_bayes_nets.ppt
cps170_bayes_nets.pptcps170_bayes_nets.ppt
cps170_bayes_nets.ppt
 
Asymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceAsymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de France
 
Workshop on Bayesian Inference for Latent Gaussian Models with Applications
Workshop on Bayesian Inference for Latent Gaussian Models with ApplicationsWorkshop on Bayesian Inference for Latent Gaussian Models with Applications
Workshop on Bayesian Inference for Latent Gaussian Models with Applications
 
Regression Analysis.pdf
Regression Analysis.pdfRegression Analysis.pdf
Regression Analysis.pdf
 
baysian in machine learning in Supervised Learning .pptx
baysian in machine learning in Supervised Learning .pptxbaysian in machine learning in Supervised Learning .pptx
baysian in machine learning in Supervised Learning .pptx
 
Bayesian network
Bayesian networkBayesian network
Bayesian network
 
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...
Solutions Manual for College Algebra Concepts Through Functions 3rd Edition b...
 
maths_formula_sheet.pdf
maths_formula_sheet.pdfmaths_formula_sheet.pdf
maths_formula_sheet.pdf
 
Linear Equations
Linear EquationsLinear Equations
Linear Equations
 
guid
guidguid
guid
 

Recently uploaded

RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxronsairoathenadugay
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...ThinkInnovation
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...Voces Mineras
 
DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1sinhaabhiyanshu
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchersdarmandersingh4580
 
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样wsppdmt
 
Predictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting TechniquesPredictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting TechniquesBoston Institute of Analytics
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Klinik kandungan
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token PredictionNABLAS株式会社
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444saurabvyas476
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareGraham Ware
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshareraiaryan448
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格q6pzkpark
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证zifhagzkk
 

Recently uploaded (20)

RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
 
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted KitAbortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
 
DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchers
 
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
 
Predictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting TechniquesPredictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting Techniques
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 

Bayesian Inference Analysis using R Programming

  • 2. Three students are constructing their prior belief about π, the proportion of Hamilton residents who support building a casino in Hamilton. Prior distributions Anna prior mean is 0.2 prior standard deviation is 0.08 beta distribution(a, b) Bart Uniform Prior p(π) = 1 for 0 <= π <=1. Beta distribution a = b = 1 Chris Trapezoidal shape continuous prior
  • 3. Compute Anna's prior distribution (beta distribution) and equivalent sample size. • Mean = π̥ = 0.2 σ̥ = Standard deviation = 0.8 π̥= 𝑎𝑎 (𝑎𝑎+𝑏𝑏) 0.2 = 𝑎𝑎 (𝑎𝑎+𝑏𝑏) b = 4a σ̥= ̥ π 1− ̥ π 𝑎𝑎+𝑏𝑏+1 0.082 = 0.2 1− 0.2 𝑎𝑎+𝑏𝑏+1 0.0064 = 0.16 (5𝑎𝑎+1) 𝑏𝑏 = 4𝑎𝑎 a = 4.8 b= 19.2 � 𝑒𝑒𝑒𝑒 = 𝑎𝑎 + 𝑏𝑏 + 1 = 4.8 +19.2 +1 = 25 Prior Distribution  Beta distribution (a = 4.8 , b = 19.2)
  • 4. Bart's prior distribution (beta distribution) and equivalent sample size. • uniform prior : a = b = 1 • Equivalent sample size is  a + b + 1 = 3 Prior Distribution  Beta distribution (a = 1 , b = 1)
  • 5. Chris's prior probability - Trapezoidal shape. Area=(0.5*2*0.1)+(2*0.2)+(0.5*2*0.2)=0.6 ≠ 1
  • 6. Find g(π). • 0 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟏𝟏 𝟎𝟎. 𝟏𝟏 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟑𝟑 𝟎𝟎. 𝟑𝟑 ≤ 𝝅𝝅 ≤ 𝟎𝟎. 𝟓𝟓 • Y = m X + C Y = m X + C Y = m X + C • 1.0=m * 0.05 + 0 2 = 0*X + C 1.0 = 0.4 *(-2.0/0.2) + C • m=20 C=2 C=5 • Y=20𝝅𝝅 Y=2 Y= 5-10 𝝅𝝅 g (𝛑𝛑 ) = � 𝟐𝟐𝟐𝟐𝟐𝟐 ; 𝟎𝟎 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟏𝟏 𝟐𝟐 ; 𝟎𝟎. 𝟏𝟏 ≤ 𝛑𝛑 ≤ 𝟎𝟎. 𝟑𝟑 𝟓𝟓 − 𝟏𝟏𝟏𝟏 𝛑𝛑 ; 𝟎𝟎. 𝟑𝟑 ≤ 𝝅𝝅 ≤ 𝟎𝟎. 𝟓𝟓
  • 7. Is g(π) a proper density? Does it have to be proper prior to find the posterior distribution. • To check if g(π) is a proper density, we need to ensure that its integral over the entire real line is equal to 1. • In this case, the integral can be calculated by summing the areas of the trapezoids. • Area=(0.5*2*0.1)+(2*0.2)+(0.5*2*0.2)=0.6 ≠ 1 • Area of the above graph is not equal to 1. • However; this is not a problem since the relative weights given by the shape of the distribution are all that is needed since the constant will cancel out. So, g (𝛑𝛑 ) is not a proper density.
  • 8. Posterior Distribution of all three students • The posterior distribution for each student can be obtained using Bayes' theorem, • y = 26 successes out of n = 100 trials For Anna, (a = 4.8, b= 19.2) • PosteriorAnna ∝ Beta(y+a ,(n-y)+b) • P( 𝛑𝛑| 𝐲𝐲) α P(𝛑𝛑) x P(Y| 𝛑𝛑) • P( 𝛑𝛑| 𝐲𝐲) α {(𝛑𝛑𝟒𝟒.𝟖𝟖−𝟏𝟏 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏.𝟐𝟐−𝟏𝟏) x (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐)} • P( 𝛑𝛑| 𝐲𝐲) α Beta(a=30.8, b=93.2) Posterior ∝ Likelihood × Prior
  • 9. • for Bart, • PosteriorBart ∝ Beta(y+a ,(n-y)+b) • P( 𝛑𝛑| 𝐲𝐲) α P(𝛑𝛑) x P(Y| 𝛑𝛑) • P( 𝛑𝛑| 𝐲𝐲) α {(𝛑𝛑𝟏𝟏−𝟏𝟏 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏−𝟏𝟏 ) x (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐 )} • P( 𝛑𝛑| 𝐲𝐲) α Beta(a=27, b=75)
  • 10. Now, we need to integrate this unnormalized posterior over the entire parameter space (0 to 0.5) to normalize it. This is a numerical integration task that typically requires the use of specialized software or programming libraries. • For Chris, • PosteriorChris​ ∝ Trapezoidal(g(π)) 1.For 0≤ 𝛑𝛑 ≤0.1: Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐) ×(20𝛑𝛑) 2.For 0.1≤ 𝛑𝛑 ≤0.3: Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐) × (2) 3.For 0.3≤ 𝛑𝛑 ≤0.5: Posterior(𝛑𝛑 ∣y)∝ (𝛑𝛑𝟐𝟐𝟐𝟐 (𝟏𝟏 − 𝛑𝛑)𝟏𝟏𝟏𝟏𝟏𝟏−𝟐𝟐𝟐𝟐 ) ×(5−10 𝛑𝛑) Normalized Posterior(π ∣y)= Posterior(π ∣y) � 0 1 2 Posterior(π ∣y) 𝑑𝑑π
  • 11. Plots of prior distributions and posterior distributions • We see that the three students end up with very similar posteriors, despite starting with priors having quite 3 different shapes.
  • 12. Plots of prior distributions and posterior distribution using software R.
  • 13. Plots of prior distributions and posterior distribution using software R.
  • 14. Conclusion • Anna thinks that the prior distribution is the beta distribution. • But Bart doesn't know the local feeling about casinos, so he uses a uniform distribution. • And Chris thinks it's a Trapezoidal distribution. • So prior distributions are different. • But the posterior distributions, are same for all three. The plot helps visualize how different prior beliefs influence the update process in Bayesian inference.