Monte Carlo integration

Similar documents
Markov Chain Monte Carlo

(5) Multi-parameter models - Gibbs sampling. ST440/540: Applied Bayesian Analysis

Advanced Statistical Modelling

Computational statistics

Principles of Bayesian Inference

17 : Markov Chain Monte Carlo

MCMC algorithms for fitting Bayesian models

MCMC Methods: Gibbs and Metropolis

Closed-form Gibbs Sampling for Graphical Models with Algebraic constraints. Hadi Mohasel Afshar Scott Sanner Christfried Webers

MCMC and Gibbs Sampling. Kayhan Batmanghelich

Markov Chain Monte Carlo, Numerical Integration

ST 740: Markov Chain Monte Carlo

STAT 425: Introduction to Bayesian Analysis

Metropolis Hastings. Rebecca C. Steorts Bayesian Methods and Modern Statistics: STA 360/601. Module 9

Introduction to Computational Biology Lecture # 14: MCMC - Markov Chain Monte Carlo

Introduction to Bayesian Statistics and Markov Chain Monte Carlo Estimation. EPSY 905: Multivariate Analysis Spring 2016 Lecture #10: April 6, 2016

Metropolis-Hastings Algorithm

CSC 2541: Bayesian Methods for Machine Learning

Learning the hyper-parameters. Luca Martino

Markov chain Monte Carlo Lecture 9

Reminder of some Markov Chain properties:

Bayesian Networks in Educational Assessment

Markov Chain Monte Carlo methods

MCMC: Markov Chain Monte Carlo

CS 343: Artificial Intelligence

CPSC 540: Machine Learning

Introduction to Machine Learning CMU-10701

CS242: Probabilistic Graphical Models Lecture 7B: Markov Chain Monte Carlo & Gibbs Sampling

A = {(x, u) : 0 u f(x)},

Bayesian Methods for Machine Learning

MCMC Review. MCMC Review. Gibbs Sampling. MCMC Review

Bayesian Methods in Multilevel Regression

Lecture 6: Markov Chain Monte Carlo

Markov chain Monte Carlo

CSE 546 Midterm Exam, Fall 2014

Example of MC for Continuous State Space

STA 4273H: Statistical Machine Learning

Introduc)on to Bayesian Methods

27 : Distributed Monte Carlo Markov Chain. 1 Recap of MCMC and Naive Parallel Gibbs Sampling

Bayesian Inference and Decision Theory

Computation and Monte Carlo Techniques

Stat 516, Homework 1

April 20th, Advanced Topics in Machine Learning California Institute of Technology. Markov Chain Monte Carlo for Machine Learning

Bayes Nets: Sampling

Monte Carlo in Bayesian Statistics

Markov chain Monte Carlo

Bayesian Inference and MCMC

Mathematical Statistics. Gregg Waterman Oregon Institute of Technology

Markov Chain Monte Carlo

Probabilistic Graphical Models Lecture 17: Markov chain Monte Carlo

Bayesian nonparametrics

16 : Approximate Inference: Markov Chain Monte Carlo

0.24 adults 2. (c) Prove that, regardless of the possible values of and, the covariance between X and Y is equal to zero. Show all work.

STA 4273H: Statistical Machine Learning

Monte Carlo Methods. Leon Gu CSD, CMU

Computer Vision Group Prof. Daniel Cremers. 10a. Markov Chain Monte Carlo

Bayesian Linear Regression

Lecture Notes based on Koop (2003) Bayesian Econometrics

Markov Networks.

Markov Chain Monte Carlo methods

Stat 451 Lecture Notes Markov Chain Monte Carlo. Ryan Martin UIC

Bayesian Classification and Regression Trees

Bayesian Linear Models

Markov Chain Monte Carlo (MCMC)

16 : Markov Chain Monte Carlo (MCMC)

SAMPLING ALGORITHMS. In general. Inference in Bayesian models

MARKOV CHAIN MONTE CARLO

Recall Discrete Distribution. 5.2 Continuous Random Variable. A probability histogram. Density Function 3/27/2012

Markov Chain Monte Carlo Inference. Siamak Ravanbakhsh Winter 2018

Bayesian Phylogenetics:

Computer Vision Group Prof. Daniel Cremers. 11. Sampling Methods: Markov Chain Monte Carlo

Calibration of Stochastic Volatility Models using Particle Markov Chain Monte Carlo Methods

MCMC for Cut Models or Chasing a Moving Target with MCMC

Bayesian Linear Models

Part 8: GLMs and Hierarchical LMs and GLMs

Bayesian Inference. Sudhir Shankar Raman Translational Neuromodeling Unit, UZH & ETH. The Reverend Thomas Bayes ( )

Machine Learning for Data Science (CS4786) Lecture 24

Covariance and Correlation Class 7, Jeremy Orloff and Jonathan Bloom

References. Markov-Chain Monte Carlo. Recall: Sampling Motivation. Problem. Recall: Sampling Methods. CSE586 Computer Vision II

Modelling Operational Risk Using Bayesian Inference

Markov Chain Monte Carlo Methods

CS 188: Artificial Intelligence. Bayes Nets

LECTURE 15 Markov chain Monte Carlo

Sampling Algorithms for Probabilistic Graphical models

The Bayesian Choice. Christian P. Robert. From Decision-Theoretic Foundations to Computational Implementation. Second Edition.

Dynamic models. Dependent data The AR(p) model The MA(q) model Hidden Markov models. 6 Dynamic models

Outline. Binomial, Multinomial, Normal, Beta, Dirichlet. Posterior mean, MAP, credible interval, posterior distribution

Forward Problems and their Inverse Solutions

Bayesian data analysis in practice: Three simple examples

Bayesian Computation in Color-Magnitude Diagrams

Down by the Bayes, where the Watermelons Grow

The lmm Package. May 9, Description Some improved procedures for linear mixed models

Markov-Chain Monte Carlo

Multilevel Statistical Models: 3 rd edition, 2003 Contents

Doing Bayesian Integrals

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm

I. Bayesian econometrics

Markov Chain Monte Carlo Using the Ratio-of-Uniforms Transformation. Luke Tierney Department of Statistics & Actuarial Science University of Iowa

DAG models and Markov Chain Monte Carlo methods a short overview

( ) ( ) Monte Carlo Methods Interested in. E f X = f x d x. Examples:

Transcription:

Monte Carlo integration Eample of a Monte Carlo sampler in D: imagine a circle radius L/ within a square of LL. If points are randoml generated over the square, what s the probabilit to hit within circle? B algebra: pl/ /L = p/4. B simulation: K P S K This also provides a Monte Carlo appro of p. k k { S}

Monte Carlo integration Wanted: e.g. posterior mean E X p X d But assume we do not have conjugate priors, no closed form solution. Could tr numerical integration methods. Or Monte Carlo: draw random i.i.d samples k from the distribution, k=,.,k. large K. K k E X K k k ~ p X

Monte Carlo integration Even if we had solved the densit, it can be difficult to evaluate E g X Note also: So that we can approimate probabilities b And likewise an quantiles. 3 0 } { X S P X S P X S P X E S K k k S K X S P } {

Monte Carlo integration What remains is to generate samples from the correct distribution. This is eas for known distributions, just read the manual of our software. N-dimensional distributions? Nonstandard distributions? Need other sampling methods than directl drawing i.i.d. 4

Monte Carlo Markov chain Innovation: Construct a sampler that works as a Markov chain, for which stationar distribution eists, and this stationar distribution is the same as our target distribution. 5

Gibbs sampler Gibbs sampling in D Eample: uniform distribition in a triangle. Y 0 X f }, {, 0, 0, 6

Gibbs sampler Gibbs sampling in D Remember product rule: p, = p p = p p Solve the marginal densit p Then: p =p,/p 7 d d d p p 0 0 } 0, 0, { 0,,

Gibbs sampler Gibbs sampling in D Solve the conditional densit: Note: above it would suffice to recognize p up to a constant term, so that solving p is not necessar. Similarl, get p = U0,-. 8 0,,, } 0, { } 0, 0, { U p p p

Gibbs sampler Gibbs sampling in D Starting from the joint densit p,, we have obtained two important conditional densities: p and p Gibbs algorithm is then: start from 0, 0. Set k=. sample k from p k- 3 sample k from p k. Set k=k+. 4 go to until sufficientl large sample. These samples are no longer i.i.d. 9

Gibbs sampler start Y end 0 X 0

0.0 0. 0.4 0.6 0.8 In R, ou could: Gibbs sampler 0.0 0. 0.4 0.6 0.8

Gibbs sampler Jumping around? Possible problems.?

Gibbs sampler Consider again the binomial model, conditional to N Joint distribution p,x N can be epressed either as px,np N or p X,NpX N. From the first, we recognize px,n=binn, with e.g. uniform prior p N=p. Then, we would know p X,N = BetaX+,N-X+. This gives p X and px for Gibbs. 3

Gibbs sampler Consider again the binomial model, conditional to N Gibbs sampling X, gives the joint distribution of X and. [ We know both conditional densities, but it would be also possible to obtain p X b Monte Carlo sampling from the joint p,x, and then accepting onl those,x-pairs for which X takes a given value. This idea is used in Approimate Baesian Computation ABC. ] 4

Gibbs sampler Binomial model, conditional to N, in R: n<-0; p <- numeric; <- numeric p[] <- 0.5; [] <- 0 # initial values fori in :000{ p[i] <- rbeta,[i-]+,n-[i-]+ [i] <- rbinom,n,p[i] } plot,p 5

Gibbs and normal densit D normal densit: Marg. densities p and p are both N0, Conditional densit p =p,/p is 6, 0 0 ~ N Y X ep, p p, ep p N p

Gibbs and normal densit Gibbs would then be sampling from: p = N,- p = N,- This can mi slowl if X & Y heavil correlated. Recall the posterior pm,s X,,X n This is a D problem. Assume improper prior p m, s / s Then we can solve pm s,x = N X i /n, s /n And pt m,x = gamma n/, 0.5 X i -m This makes Gibbs! tr this with R 7

Net time ou estimate m,s from a sample X,,X n, assuming normal model, tr sampling the posterior distribution: X <- rnorm40,0, # generate eample dataset, n=40, mean=0,sd= m[] <- mean; t[] <- /sd*sd # initial values fori in :000{ # Gibbs sampling m[i] <- rnorm,mean,sqrt/t[i-]/40; t[i] <- rgamma,40/,0.5*sum[:40]-m[i]^ } 8

Metropolis-Hastings This is a ver general purpose sampler The core is: proposal distribution and acceptance probabilit. At each iteration: Random draw is obtained from proposal densit Q * i-, which can depend on previous iteration. Simpl, it could be U i- - L/, i- + L/. 9

Metropolis-Hastings At each iteration: Proposal is accepted with probabilit i p * data Q * r min, i i p data Q * Note how little we need to know about p data! Normalizing constant cancels out from the ratio. Enough to be able to evaluate prior and likelihood terms. Proposals too far accepted rarel slow sampler Proposals too near small moves slow sampler Acceptance probabilit ideall about 0%-40% Gibbs sampler is a special case of MH-sampler In Gibbs, the acceptance probabilit is. Block sampling also possible. 0

Metropolis-Hastings Sampling from N0,, using MH-algorithm:

MCMC convergence Remember to monitor for convergence! Chain is onl approaching the target densit, when iterating a long time, k. Convergence can be ver slow in some cases. Autocorrelations between iterations are then large makes sense to take a thinned sample. Sstematic patterns, trends, sticking, indicate problems. Pa attention to starting values! Tr different values in different MCMC chains. discard burn-in period.

MCMC convergence Can onl diagnose poor convergence, but cannot full prove a good one! e.g. multimodal densities. 0.8 0.6 0.4 0. 0.0 p[] chains :4 Target densit 0000 40000 iteration 3

MCMC in BUGS Man different samplers, some of them are implemented in WinBUGS/OpenBUGS. Net, we leave the sampling for BUGS, and onl consider building the models which define a posterior distribution, and running the sampling in BUGS, and assessing the results. 4