Monte Carlo sampling

Size: px
Start display at page:

Download "Monte Carlo sampling"

Transcription

1 1 y u theta 0 x 1 Monte Carlo sampling Problem 1 Suppose we want to sample uniformly at random from the triangle defined by the points (0,0), (0,1), (1,0). First Sampling Algorithm: We decide to do this by sampling θ U(0,π/2), U U(0,1) and then the coordinates X = U cos(θ) and Y = U sin(θ). The sample (X,Y ) is retained if it is inside the triangle, i.e. if X + Y < 1. mc.ss<-3000 postscript("mcplot_1.ps") plot(c(0,1),c(0,1),type="n") for(i in 1:mc.ss) { theta<-runif(1)*pi/2 u<-runif(1) x<-u*cos(theta) y<-u*sin(theta) if((y+x)<1) points(x,y) } dev.off() 1

2 c(0, 1) c(0, 1) Figure 1: Sample of size 3000 obtained using the first sampling algorithm The plot shows that the procedure does not sample from the correct distribution since the vertex (0,0) is preferred by the sample. Alternatively, we can use the following second sampling algorithm: X U(0,1), and Y U(0,1 X). postscript("mcplot_2.ps") plot(c(0,1),c(0,1),type="n") for(i in 1:mc.ss) { x<-runif(1) y<-runif(1)*(1-x) points(x,y) } dev.off() This one doesn t work either. The right vertex is obviously favored by the sample. 2

3 c(0, 1) c(0, 1) Figure 2: Sample of size 3000 obtained using the second sampling algorithm The third alternative is to sample uniformly in the unit square and retain only the points in the triangle. postscript("mcplot_3.ps") plot(c(0,1),c(0,1),type="n") for(i in 1:mc.ss) { x<-runif(1) y<-runif(1) if((x+y)<1) points(x,y) } dev.off() This is correct but rather inefficient. For a fourth sampling algorithm one can start by computing the marginal density of X as f(x) = 2(1 x) if 0 x 1. We can use the following algorithm for sampling : X f( ), and Y U(0,1 X). 3

4 c(0, 1) c(0, 1) Figure 3: Sample of size 3000 obtained using the third sampling algorithm postscript("mcplot_4.ps") plot(c(0,1),c(0,1),type="n") for(i in 1:mc.ss) { u<-runif(1) x<-1-sqrt(1-u) y<-runif(1)*(1-x) points(x,y) } dev.off() Of all four, the fourth sampling algorithm is correct and efficient! 4

5 c(0, 1) c(0, 1) Figure 4: Sample of size 3000 obtained using the fourth sampling algorithm Importance sampling Suppose we want to compute the mean of the following mixture of distributions: f(x) = 0.4n(x 0,1) + 0.6n(x 3,1) = 0.4exp( x 2 /2)/ 2π + 0.6exp( (x 3) 2 /2)/ 2π. The true value is = 1.8. The estimate is ˆµ = m i=1 w iy i m i=1 w i In the first scenario we consider the importance density to be n(x 0,1.5). We examine the Monte Carlo error in terms of bias and variance. We use m = 1000; in order to obtain the Monte Carlo error we replicate the simulation experiment 500 times.. m<-1000 rep<-500 target<-function(x) {tx<- 0.4 *exp(-x^2/2)/sqrt(2*pi)+ 0.6 *exp(-(x-3)^2/2)/sqrt(2*pi) tx} proposal<-function(x) {px<- dnorm(x,0,sqrt(1.5)) px } 5

6 w<-c() y<-c() hat.mu<-c() for(j in 1:rep){ for(i in 1:m){ y[i]<-rnorm(1,0,sqrt(1.5)) w[i]<-target(y[i])/proposal(y[i])} hat.mu[j]<- sum(w*y)/sum(w)} > mean(hat.mu) [1] > sqrt(var(hat.mu)) [1] For a second scenario we consider the proposal to be t(x 1), the student distribution with one degrees of freedom. proposal.t<-function(x) { px<- dt(x,1) px } hat.t.mu<-c() for(j in 1:rep){ for(i in 1:m){ y[i]<-rt(1,1) w[i]<-target(y[i])/proposal.t(y[i])} hat.t.mu[j]<- sum(w*y)/sum(w)} > mean(hat.t.mu) 6

7 1.798 > sqrt(var(hat.t.mu)) [1] par(mfrow=c(2,2)) a<-seq(-10,10,0.1) b1<-dnorm(a,0,sqrt(1.5)) b2<-0.4*dnorm(a)+0.6*dnorm(a,3,1) plot(a,b1,type="l") lines(a,b2,lty=3) legend(locator(1),c(" target "), lty=3, cex=0.8) legend(locator(1),c(" proposal "), lty=1, cex=0.8) hist(hat.mu,nclass=20,prob=t) b1.t<-dt(a,1) b2<-0.4*dnorm(a)+0.6*dnorm(a,3,1) plot(a,b1.t,type="l") lines(a,b2,lty=3) legend(locator(1),c(" target "), lty=3, cex=0.8) legend(locator(1),c(" proposal "), lty=1, cex=0.8) hist(hat.t.mu,nclass=30,prob=t) 7

8 b target proposal a hat.mu[, 1] b1.t target proposal a hat.t.mu[, 1] 8

9 m i=1 Alternatively we can use µ = w iy i m m<-1000 rep<-500 w<-c() y<-c() hat.mu2<-c() for(j in 1:rep){ for(i in 1:m){ y[i]<-rnorm(1,0,sqrt(1.5)) w[i]<-target(y[i])/proposal(y[i])} hat.mu2[j]<- sum(w*y)/m} > mean(hat.mu2) [1] > sqrt(var(hat.mu2)) [1] Same approach but using t(x 1) as a proposal. hat.t.mu2<-c() for(j in 1:rep){ for(i in 1:m){ y[i]<-rt(1,1) w[i]<-target(y[i])/proposal.t(y[i])} hat.t.mu2[j]<- sum(w*y)/sum(w)} > mean(hat.t.mu2) [1] > sqrt(var(hat.t.mu2)) 9

10 [1] postscript( importance_plot2.ps ) par(mfrow=c(2,2)) a<-seq(-10,10,0.1) b1<-dnorm(a,0,sqrt(1.5)) b2<-0.4*dnorm(a)+0.6*dnorm(a,3,1) plot(a,b1,type="l") lines(a,b2,lty=3) hist(hat.mu2,nclass=30,prob=t) b1.t<-dt(a,1) b2<-0.4*dnorm(a)+0.6*dnorm(a,3,1) plot(a,b1.t,type="l") lines(a,b2,lty=3) hist(hat.t.mu2,nclass=30,prob=t) dev.off() 10

11 Histogram of hat.mu2 b Density a hat.mu2 Histogram of hat.t.mu2 b1.t Density a hat.t.mu2 11

12 We consider the bivariate distribution Markov Chain Monte Carlo ( π(x 1,x 2 ) exp 1 ) 2 (Ax2 1 x2 2 + x2 1 + x2 2 2Bx 1x2 2C 1 x 1 2C 2 x 2 ), with A = 8,B = 0,C 1 = 4,C 2 = 4. The conditional distributions can be easily determined to be normals (incidentally, this is one example where the marginals are Gaussian but the joint distribution is not Gaussian). π(x 1 x 2 ) = N((Bx 2 + C 1 )/(Ax ),1/(Ax )) π(x 2 x 1 ) = N((Bx 2 + C 2 )/(Ax ),1/(Ax )) So we can start by implementing a Gibbs sampling algorithm. Gibbs Sampling fun<-function(x1=1,x2=1,a=1,b=1,c1=1,c2=1) {rez<-exp(-0.5*(a*x1^2*x2^2+x1^2+x2^2-2*b*x1*x2-2*c1*x1-2*c2*x2)) return(rez) } A=8; B=0; C1=4; C2=4; x<-seq(-10,10,0.2) y<-seq(-10,10,0.2) par(mfrow=c(1,1)) eval<-150 gelmeng<-array(0,c(eval,eval)) co1<-ppoints(eval)*10-2 co2<-ppoints(eval)*10-2 for(i in 1:eval){ for(j in 1:eval){ gelmeng[i,j]<-sum(fun(co1[i],co2[j],a,b,c1,c2)) }} 12

13 dens<-gelmeng/max(gelmeng) contour(co1,co2,t(dens),levels=c(0,0.05,0.1,1,2,4,8,10)/100,main="gibbs Sampling") nsim<-2000; nchains=2; #define the matrices used to store the samples x.sim<-matrix(0,nrow=nchains,ncol=nsim); y.sim<-matrix(0,nrow=nchains,ncol=nsim); #we initialize the chains x.sim[,1]<-rnorm(nchains,mean=1,sd=1); y.sim[,1]<-rnorm(nchains,mean=1,sd=1); for(j in 2:nsim){ for(i in 1:nchains){ x.sim[i,j]<-rnorm(1,(b*y.sim[i,j-1]+c1)/(a*y.sim[i,j-1]^2+1),1/(a*y.sim[i,j-1]^2+1)) y.sim[i,j]<-rnorm(1, (B*x.sim[i,j]+C2)/(A*x.sim[i,j]^2+1),1/(A*x.sim[i,j]^2+1)) points(x.sim[i,j],y.sim[i,j],pch=i)}} Alternatively, we can try to run a few Metropolis-Hastings samplers with various proposals: Independent Metropolis Metropolis-Hastings Sampling We use as a proposal a mixture of two normals q(x,y) = 0.5n(x,y;(0,4),diag(0.1, 2)) + 0.5n(x,y;(4,0),diag(2,0.1)) library(mvtnorm) logdproposal<-function(x=1,y=1){ rez<-0.5*dmvnorm(c(x,y),c(0,4),diag(c(0.1,2)))+ 0.5*dmvnorm(c(x,y),c(4,0),diag(c(2,0.1))) return(log(rez)) } 13

14 Gibbs Sampling sample.proposal<-function(u=0.1) { if(u<=0.5) rez<-rmvnorm(1,c(0,4),diag(c(0.1,2))) if(u>0.5) rez<-rmvnorm(1,c(4,0),diag(c(2,0.1))) return(rez[1,]) } logtarget<-function(x1=1,x2=1,a=1,b=1,c1=1,c2=1) {rez<- (-0.5)*(A*x1^2*x2^2+x1^2+x2^2-2*B*x1*x2-2*C1*x1-2*C2*x2) return(rez) } nsim<-1000; nchains=2; contour(co1,co2,t(dens),levels=c(0,0.05,0.1,1,2,4,8,10)/100, main="independent Metropolis") #define the matrices used to store the samples x.sim<-matrix(0,nrow=nchains,ncol=nsim); 14

15 y.sim<-matrix(0,nrow=nchains,ncol=nsim); #we initialize the chains x.sim[,1]<-rnorm(nchains,mean=1,sd=5); y.sim[,1]<-rnorm(nchains,mean=1,sd=5); count<-0 for(j in 2:nsim){ for(i in 1:nchains){ w<-runif(1) z.prop<-sample.proposal(w) ratio<- logtarget(z.prop[1],z.prop[2],a,b,c1,c2)- logtarget(x.sim[i,j-1],y.sim[i,j-1],a,b,c1,c2)+ logdproposal(x.sim[i,j-1],y.sim[i,j-1])-logdproposal(z.prop[1],z.prop[2]) ratio<-exp(ratio) v<-runif(1) if(v<=ratio){ x.sim[i,j]<-z.prop[1] y.sim[i,j]<-z.prop[2] count<-count+1 } if(v>ratio) { x.sim[i,j]<-x.sim[i,j-1] y.sim[i,j]<-y.sim[i,j-1] } points(x.sim[i,j],y.sim[i,j],pch=i) }} print(count/(nsim*nchains)) 15

16 Independent Metropolis Random Walk Metropolis In general, we don t know the contour of the target so we cannot find a good independent proposal; in that case we could use a random walk Metropolis algorithm in which the proposal is q( (x,y)) = n( ;(x,y),σ 2 I 2 ). The choice of σ 2 is crucial for finding an efficient sampling algorithm. library(mvtnorm) dproposal<-function(x=1,y=1,x.old=2,y.old=2){ rez<-dmvnorm(c(x,y),c(x.old,y.old),diag(c(0.5,0.5)),log=t) return(rez) } sample.proposal<-function(x.old=1,y.old=1) { rez<-rmvnorm(1,c(x.old,y.old),diag(c(0.5,0.5))) return(rez[1,]) } 16

17 nsim<-1000; nchains=2; contour(co1,co2,t(dens),levels=c(0,0.05,0.1,1,2,4,8,10)/100, main="random Walk Metropolis") #define the matrices used to store the samples x.sim<-matrix(0,nrow=nchains,ncol=nsim); y.sim<-matrix(0,nrow=nchains,ncol=nsim); #we initialize the chains x.sim[,1]<-rnorm(nchains,mean=1,sd=1); y.sim[,1]<-rnorm(nchains,mean=1,sd=1); count<-0 for(j in 2:nsim){ for(i in 1:nchains){ w<-runif(1) z.prop<-sample.proposal(x.sim[i,j-1],y.sim[i,j-1]) ratio<- logtarget(z.prop[1],z.prop[2],a,b,c1,c2)- logtarget(x.sim[i,j-1],y.sim[i,j-1],a,b,c1,c2) ratio<-exp(ratio) v<-runif(1) if(v<=ratio){ x.sim[i,j]<-z.prop[1] y.sim[i,j]<-z.prop[2] count<-count+1 } if(v>ratio) { x.sim[i,j]<-x.sim[i,j-1] y.sim[i,j]<-y.sim[i,j-1] } points(x.sim[i,j],y.sim[i,j],pch=i)}} 17

18 Random Walk Metropolis print(count/(nsim*nchains)) 18

Markov chain Monte Carlo methods

Markov chain Monte Carlo methods Markov chain Monte Carlo methods (supplementary material) see also the applet http://www.lbreyer.com/classic.html February 9 6 Independent Hastings Metropolis Sampler Outline Independent Hastings Metropolis

More information

Bayesian Statistics Group 8th March Slice samplers. (A very brief introduction) The basic idea

Bayesian Statistics Group 8th March Slice samplers. (A very brief introduction) The basic idea Bayesian Statistics Group 8th March 2000 Slice samplers (A very brief introduction) The basic idea lacements To sample from a distribution, simply sample uniformly from the region under the density function

More information

Package gibbs.met documentation

Package gibbs.met documentation Version 1.1-2 Package gibbs.met documentation Title Naive Gibbs Sampling with Metropolis Steps Author Longhai Li of March 26, 2008 Maintainer Longhai Li

More information

Chapter 1. Introduction

Chapter 1. Introduction Chapter 1 Introduction A Monte Carlo method is a compuational method that uses random numbers to compute (estimate) some quantity of interest. Very often the quantity we want to compute is the mean of

More information

Package gibbs.met. February 19, 2015

Package gibbs.met. February 19, 2015 Version 1.1-3 Title Naive Gibbs Sampling with Metropolis Steps Author Longhai Li Package gibbs.met February 19, 2015 Maintainer Longhai Li Depends R (>=

More information

Quantitative Biology II!

Quantitative Biology II! Quantitative Biology II! Lecture 3: Markov Chain Monte Carlo! March 9, 2015! 2! Plan for Today!! Introduction to Sampling!! Introduction to MCMC!! Metropolis Algorithm!! Metropolis-Hastings Algorithm!!

More information

Missing Data Analysis for the Employee Dataset

Missing Data Analysis for the Employee Dataset Missing Data Analysis for the Employee Dataset 67% of the observations have missing values! Modeling Setup Random Variables: Y i =(Y i1,...,y ip ) 0 =(Y i,obs, Y i,miss ) 0 R i =(R i1,...,r ip ) 0 ( 1

More information

Will Monroe July 21, with materials by Mehran Sahami and Chris Piech. Joint Distributions

Will Monroe July 21, with materials by Mehran Sahami and Chris Piech. Joint Distributions Will Monroe July 1, 017 with materials by Mehran Sahami and Chris Piech Joint Distributions Review: Normal random variable An normal (= Gaussian) random variable is a good approximation to many other distributions.

More information

Optimization Methods III. The MCMC. Exercises.

Optimization Methods III. The MCMC. Exercises. Aula 8. Optimization Methods III. Exercises. 0 Optimization Methods III. The MCMC. Exercises. Anatoli Iambartsev IME-USP Aula 8. Optimization Methods III. Exercises. 1 [RC] A generic Markov chain Monte

More information

Image analysis. Computer Vision and Classification Image Segmentation. 7 Image analysis

Image analysis. Computer Vision and Classification Image Segmentation. 7 Image analysis 7 Computer Vision and Classification 413 / 458 Computer Vision and Classification The k-nearest-neighbor method The k-nearest-neighbor (knn) procedure has been used in data analysis and machine learning

More information

Monte Carlo Techniques for Bayesian Statistical Inference A comparative review

Monte Carlo Techniques for Bayesian Statistical Inference A comparative review 1 Monte Carlo Techniques for Bayesian Statistical Inference A comparative review BY Y. FAN, D. WANG School of Mathematics and Statistics, University of New South Wales, Sydney 2052, AUSTRALIA 18th January,

More information

STATISTICAL LABORATORY, April 30th, 2010 BIVARIATE PROBABILITY DISTRIBUTIONS

STATISTICAL LABORATORY, April 30th, 2010 BIVARIATE PROBABILITY DISTRIBUTIONS STATISTICAL LABORATORY, April 3th, 21 BIVARIATE PROBABILITY DISTRIBUTIONS Mario Romanazzi 1 MULTINOMIAL DISTRIBUTION Ex1 Three players play 1 independent rounds of a game, and each player has probability

More information

MSA101/MVE Lecture 5

MSA101/MVE Lecture 5 MSA101/MVE187 2017 Lecture 5 Petter Mostad Chalmers University September 12, 2017 1 / 15 Importance sampling MC integration computes h(x)f (x) dx where f (x) is a probability density function, by simulating

More information

1 Methods for Posterior Simulation

1 Methods for Posterior Simulation 1 Methods for Posterior Simulation Let p(θ y) be the posterior. simulation. Koop presents four methods for (posterior) 1. Monte Carlo integration: draw from p(θ y). 2. Gibbs sampler: sequentially drawing

More information

lecture 19: monte carlo methods

lecture 19: monte carlo methods lecture 19: monte carlo methods STAT 598z: Introduction to computing for statistics Vinayak Rao Department of Statistics, Purdue University April 3, 2019 Monte Carlo integration We want to calculate integrals/summations

More information

MCMC Methods for data modeling

MCMC Methods for data modeling MCMC Methods for data modeling Kenneth Scerri Department of Automatic Control and Systems Engineering Introduction 1. Symposium on Data Modelling 2. Outline: a. Definition and uses of MCMC b. MCMC algorithms

More information

An Efficient Model Selection for Gaussian Mixture Model in a Bayesian Framework

An Efficient Model Selection for Gaussian Mixture Model in a Bayesian Framework IEEE SIGNAL PROCESSING LETTERS, VOL. XX, NO. XX, XXX 23 An Efficient Model Selection for Gaussian Mixture Model in a Bayesian Framework Ji Won Yoon arxiv:37.99v [cs.lg] 3 Jul 23 Abstract In order to cluster

More information

Markov Chain Monte Carlo (part 1)

Markov Chain Monte Carlo (part 1) Markov Chain Monte Carlo (part 1) Edps 590BAY Carolyn J. Anderson Department of Educational Psychology c Board of Trustees, University of Illinois Spring 2018 Depending on the book that you select for

More information

Probabilistic Graphical Models

Probabilistic Graphical Models Probabilistic Graphical Models Lecture 17 EM CS/CNS/EE 155 Andreas Krause Announcements Project poster session on Thursday Dec 3, 4-6pm in Annenberg 2 nd floor atrium! Easels, poster boards and cookies

More information

Linear Modeling with Bayesian Statistics

Linear Modeling with Bayesian Statistics Linear Modeling with Bayesian Statistics Bayesian Approach I I I I I Estimate probability of a parameter State degree of believe in specific parameter values Evaluate probability of hypothesis given the

More information

Overview. Monte Carlo Methods. Statistics & Bayesian Inference Lecture 3. Situation At End Of Last Week

Overview. Monte Carlo Methods. Statistics & Bayesian Inference Lecture 3. Situation At End Of Last Week Statistics & Bayesian Inference Lecture 3 Joe Zuntz Overview Overview & Motivation Metropolis Hastings Monte Carlo Methods Importance sampling Direct sampling Gibbs sampling Monte-Carlo Markov Chains Emcee

More information

Laboratorio di Problemi Inversi Esercitazione 4: metodi Bayesiani e importance sampling

Laboratorio di Problemi Inversi Esercitazione 4: metodi Bayesiani e importance sampling Laboratorio di Problemi Inversi Esercitazione 4: metodi Bayesiani e importance sampling Luca Calatroni Dipartimento di Matematica, Universitá degli studi di Genova May 19, 2016. Luca Calatroni (DIMA, Unige)

More information

10.4 Linear interpolation method Newton s method

10.4 Linear interpolation method Newton s method 10.4 Linear interpolation method The next best thing one can do is the linear interpolation method, also known as the double false position method. This method works similarly to the bisection method by

More information

ADAPTIVE METROPOLIS-HASTINGS SAMPLING, OR MONTE CARLO KERNEL ESTIMATION

ADAPTIVE METROPOLIS-HASTINGS SAMPLING, OR MONTE CARLO KERNEL ESTIMATION ADAPTIVE METROPOLIS-HASTINGS SAMPLING, OR MONTE CARLO KERNEL ESTIMATION CHRISTOPHER A. SIMS Abstract. A new algorithm for sampling from an arbitrary pdf. 1. Introduction Consider the standard problem of

More information

Bayesian data analysis using R

Bayesian data analysis using R Bayesian data analysis using R BAYESIAN DATA ANALYSIS USING R Jouni Kerman, Samantha Cook, and Andrew Gelman Introduction Bayesian data analysis includes but is not limited to Bayesian inference (Gelman

More information

Missing Data Analysis for the Employee Dataset

Missing Data Analysis for the Employee Dataset Missing Data Analysis for the Employee Dataset 67% of the observations have missing values! Modeling Setup For our analysis goals we would like to do: Y X N (X, 2 I) and then interpret the coefficients

More information

R Programming Basics - Useful Builtin Functions for Statistics

R Programming Basics - Useful Builtin Functions for Statistics R Programming Basics - Useful Builtin Functions for Statistics Vectorized Arithmetic - most arthimetic operations in R work on vectors. Here are a few commonly used summary statistics. testvect = c(1,3,5,2,9,10,7,8,6)

More information

Approximate Bayesian Computation methods and their applications for hierarchical statistical models. University College London, 2015

Approximate Bayesian Computation methods and their applications for hierarchical statistical models. University College London, 2015 Approximate Bayesian Computation methods and their applications for hierarchical statistical models University College London, 2015 Contents 1. Introduction 2. ABC methods 3. Hierarchical models 4. Application

More information

Random Numbers Random Walk

Random Numbers Random Walk Random Numbers Random Walk Computational Physics Random Numbers Random Walk Outline Random Systems Random Numbers Monte Carlo Integration Example Random Walk Exercise 7 Introduction Random Systems Deterministic

More information

Clustering Relational Data using the Infinite Relational Model

Clustering Relational Data using the Infinite Relational Model Clustering Relational Data using the Infinite Relational Model Ana Daglis Supervised by: Matthew Ludkin September 4, 2015 Ana Daglis Clustering Data using the Infinite Relational Model September 4, 2015

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

Package atmcmc. February 19, 2015

Package atmcmc. February 19, 2015 Type Package Package atmcmc February 19, 2015 Title Automatically Tuned Markov Chain Monte Carlo Version 1.0 Date 2014-09-16 Author Jinyoung Yang Maintainer Jinyoung Yang

More information

Computer vision: models, learning and inference. Chapter 10 Graphical Models

Computer vision: models, learning and inference. Chapter 10 Graphical Models Computer vision: models, learning and inference Chapter 10 Graphical Models Independence Two variables x 1 and x 2 are independent if their joint probability distribution factorizes as Pr(x 1, x 2 )=Pr(x

More information

Today s outline: pp

Today s outline: pp Chapter 3 sections We will SKIP a number of sections Random variables and discrete distributions Continuous distributions The cumulative distribution function Bivariate distributions Marginal distributions

More information

Debugging MCMC Code. Charles J. Geyer. April 15, 2017

Debugging MCMC Code. Charles J. Geyer. April 15, 2017 Debugging MCMC Code Charles J. Geyer April 15, 2017 1 Introduction This document discusses debugging Markov chain Monte Carlo code using the R contributed package mcmc (Version 0.9-5) for examples. It

More information

R Programming: Worksheet 6

R Programming: Worksheet 6 R Programming: Worksheet 6 Today we ll study a few useful functions we haven t come across yet: all(), any(), `%in%`, match(), pmax(), pmin(), unique() We ll also apply our knowledge to the bootstrap.

More information

Curve Sampling and Geometric Conditional Simulation

Curve Sampling and Geometric Conditional Simulation Curve Sampling and Geometric Conditional Simulation Ayres Fan Joint work with John Fisher, William Wells, Jonathan Kane, and Alan Willsky S S G Massachusetts Institute of Technology September 19, 2007

More information

Probability Model for 2 RV s

Probability Model for 2 RV s Probability Model for 2 RV s The joint probability mass function of X and Y is P X,Y (x, y) = P [X = x, Y= y] Joint PMF is a rule that for any x and y, gives the probability that X = x and Y= y. 3 Example:

More information

Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00

Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00 P. Hadjidoukas, C. Papadimitriou ETH Zentrum, CTL E 13 CH-8092 Zürich High Performance Computing for Science and Engineering II Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00 Spring semester

More information

Nested Sampling: Introduction and Implementation

Nested Sampling: Introduction and Implementation UNIVERSITY OF TEXAS AT SAN ANTONIO Nested Sampling: Introduction and Implementation Liang Jing May 2009 1 1 ABSTRACT Nested Sampling is a new technique to calculate the evidence, Z = P(D M) = p(d θ, M)p(θ

More information

Simulation. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen

Simulation. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen Simulation Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen What can random numbers be used for Some applications: Simulation of complex systems MCMC (Markov Chain

More information

Approximate (Monte Carlo) Inference in Bayes Nets. Monte Carlo (continued)

Approximate (Monte Carlo) Inference in Bayes Nets. Monte Carlo (continued) Approximate (Monte Carlo) Inference in Bayes Nets Basic idea: Let s repeatedly sample according to the distribution represented by the Bayes Net. If in 400/1000 draws, the variable X is true, then we estimate

More information

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION CS580: Computer Graphics KAIST School of Computing Chapter 3 MULTI-DIMENSIONAL MONTE CARLO INTEGRATION 2 1 Monte Carlo Integration This describes a simple technique for the numerical evaluation of integrals

More information

Convergence and Efficiency of Adaptive MCMC. Jinyoung Yang

Convergence and Efficiency of Adaptive MCMC. Jinyoung Yang Convergence and Efficiency of Adaptive MCMC by Jinyoung Yang A thesis submitted in conformity with the requirements for the degree of Doctor of Philosophy Graduate Department of Statistical Sciences University

More information

Hybrid Quasi-Monte Carlo Method for the Simulation of State Space Models

Hybrid Quasi-Monte Carlo Method for the Simulation of State Space Models The Tenth International Symposium on Operations Research and Its Applications (ISORA 211) Dunhuang, China, August 28 31, 211 Copyright 211 ORSC & APORC, pp. 83 88 Hybrid Quasi-Monte Carlo Method for the

More information

Generating pseudo Normal Numbers : Ziggurat, Box Muller and R default rnorm method

Generating pseudo Normal Numbers : Ziggurat, Box Muller and R default rnorm method Generating pseudo Normal Numbers : Ziggurat, Box Muller and R default rnorm method 1 Introduction Mriganka Aulia ISI There is many methods for generating pseudo Normal Random Numbers. Here we focus on

More information

MCMC Diagnostics. Yingbo Li MATH Clemson University. Yingbo Li (Clemson) MCMC Diagnostics MATH / 24

MCMC Diagnostics. Yingbo Li MATH Clemson University. Yingbo Li (Clemson) MCMC Diagnostics MATH / 24 MCMC Diagnostics Yingbo Li Clemson University MATH 9810 Yingbo Li (Clemson) MCMC Diagnostics MATH 9810 1 / 24 Convergence to Posterior Distribution Theory proves that if a Gibbs sampler iterates enough,

More information

AN ADAPTIVE POPULATION IMPORTANCE SAMPLER. Luca Martino*, Victor Elvira\ David Luengcfi, Jukka Corander*

AN ADAPTIVE POPULATION IMPORTANCE SAMPLER. Luca Martino*, Victor Elvira\ David Luengcfi, Jukka Corander* AN ADAPTIVE POPULATION IMPORTANCE SAMPLER Luca Martino*, Victor Elvira\ David Luengcfi, Jukka Corander* * Dep. of Mathematics and Statistics, University of Helsinki, 00014 Helsinki (Finland). t Dep. of

More information

Math 265 Exam 3 Solutions

Math 265 Exam 3 Solutions C Roettger, Fall 16 Math 265 Exam 3 Solutions Problem 1 Let D be the region inside the circle r 5 sin θ but outside the cardioid r 2 + sin θ. Find the area of D. Note that r and θ denote polar coordinates.

More information

The nor1mix Package. August 3, 2006

The nor1mix Package. August 3, 2006 The nor1mix Package August 3, 2006 Title Normal (1-d) Mixture Models (S3 Classes and Methods) Version 1.0-6 Date 2006-08-02 Author: Martin Mächler Maintainer Martin Maechler

More information

arxiv: v3 [stat.co] 27 Apr 2012

arxiv: v3 [stat.co] 27 Apr 2012 A multi-point Metropolis scheme with generic weight functions arxiv:1112.4048v3 stat.co 27 Apr 2012 Abstract Luca Martino, Victor Pascual Del Olmo, Jesse Read Department of Signal Theory and Communications,

More information

An Introduction to Markov Chain Monte Carlo

An Introduction to Markov Chain Monte Carlo An Introduction to Markov Chain Monte Carlo Markov Chain Monte Carlo (MCMC) refers to a suite of processes for simulating a posterior distribution based on a random (ie. monte carlo) process. In other

More information

A Nonparametric Bayesian Approach to Detecting Spatial Activation Patterns in fmri Data

A Nonparametric Bayesian Approach to Detecting Spatial Activation Patterns in fmri Data A Nonparametric Bayesian Approach to Detecting Spatial Activation Patterns in fmri Data Seyoung Kim, Padhraic Smyth, and Hal Stern Bren School of Information and Computer Sciences University of California,

More information

Making plots in R [things I wish someone told me when I started grad school]

Making plots in R [things I wish someone told me when I started grad school] Making plots in R [things I wish someone told me when I started grad school] Kirk Lohmueller Department of Ecology and Evolutionary Biology UCLA September 22, 2017 In honor of Talk Like a Pirate Day...

More information

Convexization in Markov Chain Monte Carlo

Convexization in Markov Chain Monte Carlo in Markov Chain Monte Carlo 1 IBM T. J. Watson Yorktown Heights, NY 2 Department of Aerospace Engineering Technion, Israel August 23, 2011 Problem Statement MCMC processes in general are governed by non

More information

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R Brian S. Everitt and Torsten Hothorn CHAPTER 7 Density Estimation: Erupting Geysers and Star Clusters 7.1 Introduction 7.2 Density Estimation The three kernel

More information

Short-Cut MCMC: An Alternative to Adaptation

Short-Cut MCMC: An Alternative to Adaptation Short-Cut MCMC: An Alternative to Adaptation Radford M. Neal Dept. of Statistics and Dept. of Computer Science University of Toronto http://www.cs.utoronto.ca/ radford/ Third Workshop on Monte Carlo Methods,

More information

Expectation Maximization. Machine Learning 10701/15781 Carlos Guestrin Carnegie Mellon University

Expectation Maximization. Machine Learning 10701/15781 Carlos Guestrin Carnegie Mellon University Expectation Maximization Machine Learning 10701/15781 Carlos Guestrin Carnegie Mellon University April 10 th, 2006 1 Announcements Reminder: Project milestone due Wednesday beginning of class 2 Coordinate

More information

Kevin James. MTHSC 206 Section 15.6 Directional Derivatives and the Gra

Kevin James. MTHSC 206 Section 15.6 Directional Derivatives and the Gra MTHSC 206 Section 15.6 Directional Derivatives and the Gradient Vector Definition We define the directional derivative of the function f (x, y) at the point (x 0, y 0 ) in the direction of the unit vector

More information

Co-ordinate Geometry

Co-ordinate Geometry Co-ordinate Geometry 1. Find the value of P for which the points (1, -), (2, -6) and (p, -1) are collinear 2. If the point P (x, y) is equidistant from the points A (1,) and B(4, 1). Prove that 2x+y =

More information

Image Segmentation using Gaussian Mixture Models

Image Segmentation using Gaussian Mixture Models Image Segmentation using Gaussian Mixture Models Rahman Farnoosh, Gholamhossein Yari and Behnam Zarpak Department of Applied Mathematics, University of Science and Technology, 16844, Narmak,Tehran, Iran

More information

(c) 0 (d) (a) 27 (b) (e) x 2 3x2

(c) 0 (d) (a) 27 (b) (e) x 2 3x2 1. Sarah the architect is designing a modern building. The base of the building is the region in the xy-plane bounded by x =, y =, and y = 3 x. The building itself has a height bounded between z = and

More information

Introduction to Pattern Recognition Part II. Selim Aksoy Bilkent University Department of Computer Engineering

Introduction to Pattern Recognition Part II. Selim Aksoy Bilkent University Department of Computer Engineering Introduction to Pattern Recognition Part II Selim Aksoy Bilkent University Department of Computer Engineering saksoy@cs.bilkent.edu.tr RETINA Pattern Recognition Tutorial, Summer 2005 Overview Statistical

More information

Semiparametric Mixed Effecs with Hierarchical DP Mixture

Semiparametric Mixed Effecs with Hierarchical DP Mixture Semiparametric Mixed Effecs with Hierarchical DP Mixture R topics documented: April 21, 2007 hdpm-package........................................ 1 hdpm............................................ 2 hdpmfitsetup........................................

More information

Business Statistics: R tutorials

Business Statistics: R tutorials Business Statistics: R tutorials Jingyu He September 29, 2017 Install R and RStudio R is a free software environment for statistical computing and graphics. Download free R and RStudio for Windows/Mac:

More information

Package mederrrank. R topics documented: July 8, 2015

Package mederrrank. R topics documented: July 8, 2015 Package mederrrank July 8, 2015 Title Bayesian Methods for Identifying the Most Harmful Medication Errors Version 0.0.8 Date 2015-07-06 Two distinct but related statistical approaches to the problem of

More information

The nor1mix Package. June 12, 2007

The nor1mix Package. June 12, 2007 The nor1mix Package June 12, 2007 Title Normal (1-d) Mixture Models (S3 Classes and Methods) Version 1.0-7 Date 2007-03-15 Author Martin Mächler Maintainer Martin Maechler

More information

arxiv: v2 [stat.co] 19 Feb 2016

arxiv: v2 [stat.co] 19 Feb 2016 Noname manuscript No. (will be inserted by the editor) Issues in the Multiple Try Metropolis mixing L. Martino F. Louzada Received: date / Accepted: date arxiv:158.4253v2 [stat.co] 19 Feb 216 Abstract

More information

Parallel Adaptive Importance Sampling. Cotter, Colin and Cotter, Simon and Russell, Paul. MIMS EPrint:

Parallel Adaptive Importance Sampling. Cotter, Colin and Cotter, Simon and Russell, Paul. MIMS EPrint: Parallel Adaptive Importance Sampling Cotter, Colin and Cotter, Simon and Russell, Paul 2015 MIMS EPrint: 2015.82 Manchester Institute for Mathematical Sciences School of Mathematics The University of

More information

Digital Image Processing Laboratory: Markov Random Fields and MAP Image Segmentation

Digital Image Processing Laboratory: Markov Random Fields and MAP Image Segmentation Purdue University: Digital Image Processing Laboratories Digital Image Processing Laboratory: Markov Random Fields and MAP Image Segmentation December, 205 Introduction This laboratory explores the use

More information

Introduction to R. Biostatistics 615/815 Lecture 23

Introduction to R. Biostatistics 615/815 Lecture 23 Introduction to R Biostatistics 615/815 Lecture 23 So far We have been working with C Strongly typed language Variable and function types set explicitly Functional language Programs are a collection of

More information

Estimation of Item Response Models

Estimation of Item Response Models Estimation of Item Response Models Lecture #5 ICPSR Item Response Theory Workshop Lecture #5: 1of 39 The Big Picture of Estimation ESTIMATOR = Maximum Likelihood; Mplus Any questions? answers Lecture #5:

More information

Toward a Statistical Approach to Automatic Particle Detection in Electron Microscopy

Toward a Statistical Approach to Automatic Particle Detection in Electron Microscopy Data (a.eps and noise.eps generated by GIMP@linux) Background noise Data reduction via blocking Toward a Statistical Approach to Automatic in Electron Microscopy Data and Data Reduction Data (a.eps and

More information

R Primer for Introduction to Mathematical Statistics 8th Edition Joseph W. McKean

R Primer for Introduction to Mathematical Statistics 8th Edition Joseph W. McKean R Primer for Introduction to Mathematical Statistics 8th Edition Joseph W. McKean Copyright 2017 by Joseph W. McKean at Western Michigan University. All rights reserved. Reproduction or translation of

More information

PHYSICS 115/242 Homework 5, Solutions X = and the mean and variance of X are N times the mean and variance of 12/N y, so

PHYSICS 115/242 Homework 5, Solutions X = and the mean and variance of X are N times the mean and variance of 12/N y, so PHYSICS 5/242 Homework 5, Solutions. Central limit theorem. (a) Let y i = x i /2. The distribution of y i is equal to for /2 y /2 and zero otherwise. Hence We consider µ y y i = /2 /2 σ 2 y y 2 i y i 2

More information

Warped Mixture Models

Warped Mixture Models Warped Mixture Models Tomoharu Iwata, David Duvenaud, Zoubin Ghahramani Cambridge University Computational and Biological Learning Lab March 11, 2013 OUTLINE Motivation Gaussian Process Latent Variable

More information

Recap: The E-M algorithm. Biostatistics 615/815 Lecture 22: Gibbs Sampling. Recap - Local minimization methods

Recap: The E-M algorithm. Biostatistics 615/815 Lecture 22: Gibbs Sampling. Recap - Local minimization methods Recap: The E-M algorithm Biostatistics 615/815 Lecture 22: Gibbs Sampling Expectation step (E-step) Given the current estimates of parameters λ (t), calculate the conditional distribution of latent variable

More information

Estimating Labels from Label Proportions

Estimating Labels from Label Proportions Estimating Labels from Label Proportions Novi Quadrianto Novi.Quad@gmail.com The Australian National University, Australia NICTA, Statistical Machine Learning Program, Australia Joint work with Alex Smola,

More information

Inference and Representation

Inference and Representation Inference and Representation Rachel Hodos New York University Lecture 5, October 6, 2015 Rachel Hodos Lecture 5: Inference and Representation Today: Learning with hidden variables Outline: Unsupervised

More information

Statistical techniques for data analysis in Cosmology

Statistical techniques for data analysis in Cosmology Statistical techniques for data analysis in Cosmology arxiv:0712.3028; arxiv:0911.3105 Numerical recipes (the bible ) Licia Verde ICREA & ICC UB-IEEC http://icc.ub.edu/~liciaverde outline Lecture 1: Introduction

More information

EN1610 Image Understanding Lab # 4: Corners, Interest Points, Hough Transform

EN1610 Image Understanding Lab # 4: Corners, Interest Points, Hough Transform EN1610 Image Understanding Lab # 4: Corners, Interest Points, Hough Transform The goal of this fourth lab is to ˆ Learn how to detect corners, and use them in a tracking application ˆ Learn how to describe

More information

The Multi Stage Gibbs Sampling: Data Augmentation Dutch Example

The Multi Stage Gibbs Sampling: Data Augmentation Dutch Example The Multi Stage Gibbs Sampling: Data Augmentation Dutch Example Rebecca C. Steorts Bayesian Methods and Modern Statistics: STA 360/601 Module 8 1 Example: Data augmentation / Auxiliary variables A commonly-used

More information

Markov chain Monte Carlo sampling

Markov chain Monte Carlo sampling Markov chain Monte Carlo sampling If you are trying to estimate the best values and uncertainties of a many-parameter model, or if you are trying to compare two models with multiple parameters each, fair

More information

Cluster Analysis. Jia Li Department of Statistics Penn State University. Summer School in Statistics for Astronomers IV June 9-14, 2008

Cluster Analysis. Jia Li Department of Statistics Penn State University. Summer School in Statistics for Astronomers IV June 9-14, 2008 Cluster Analysis Jia Li Department of Statistics Penn State University Summer School in Statistics for Astronomers IV June 9-1, 8 1 Clustering A basic tool in data mining/pattern recognition: Divide a

More information

Unsupervised Texture Image Segmentation Using MRF- EM Framework

Unsupervised Texture Image Segmentation Using MRF- EM Framework Journal of Advances in Computer Research Quarterly ISSN: 2008-6148 Sari Branch, Islamic Azad University, Sari, I.R.Iran (Vol. 4, No. 2, May 2013), Pages: 1-13 www.jacr.iausari.ac.ir Unsupervised Texture

More information

MAT 343 Laboratory 4 Plotting and computer animation in MATLAB

MAT 343 Laboratory 4 Plotting and computer animation in MATLAB MAT 4 Laboratory 4 Plotting and computer animation in MATLAB In this laboratory session we will learn how to. Plot in MATLAB. The geometric properties of special types of matrices (rotations, dilations,

More information

Note Set 4: Finite Mixture Models and the EM Algorithm

Note Set 4: Finite Mixture Models and the EM Algorithm Note Set 4: Finite Mixture Models and the EM Algorithm Padhraic Smyth, Department of Computer Science University of California, Irvine Finite Mixture Models A finite mixture model with K components, for

More information

Computational Statistics General Background Information

Computational Statistics General Background Information Computational Statistics General Background Information Brief introduction to R. R functions. Monte Carlo methods in statistics. Uniform random number generation. Random number generation in R. 1 A Little

More information

DD2429 Computational Photography :00-19:00

DD2429 Computational Photography :00-19:00 . Examination: DD2429 Computational Photography 202-0-8 4:00-9:00 Each problem gives max 5 points. In order to pass you need about 0-5 points. You are allowed to use the lecture notes and standard list

More information

Chapter 3. Bootstrap. 3.1 Introduction. 3.2 The general idea

Chapter 3. Bootstrap. 3.1 Introduction. 3.2 The general idea Chapter 3 Bootstrap 3.1 Introduction The estimation of parameters in probability distributions is a basic problem in statistics that one tends to encounter already during the very first course on the subject.

More information

Level-set MCMC Curve Sampling and Geometric Conditional Simulation

Level-set MCMC Curve Sampling and Geometric Conditional Simulation Level-set MCMC Curve Sampling and Geometric Conditional Simulation Ayres Fan John W. Fisher III Alan S. Willsky February 16, 2007 Outline 1. Overview 2. Curve evolution 3. Markov chain Monte Carlo 4. Curve

More information

Bayesian Modelling with JAGS and R

Bayesian Modelling with JAGS and R Bayesian Modelling with JAGS and R Martyn Plummer International Agency for Research on Cancer Rencontres R, 3 July 2012 CRAN Task View Bayesian Inference The CRAN Task View Bayesian Inference is maintained

More information

Modern Model Estimation Part 1: Gibbs Sampling

Modern Model Estimation Part 1: Gibbs Sampling 4 Modern Model Estimation Part 1: Gibbs Sampling The estimation of a Baesian model is the most difficult part of undertaking a Baesian analsis. Given that researchers ma use different priors for an particular

More information

Scalable Bayes Clustering for Outlier Detection Under Informative Sampling

Scalable Bayes Clustering for Outlier Detection Under Informative Sampling Scalable Bayes Clustering for Outlier Detection Under Informative Sampling Based on JMLR paper of T. D. Savitsky Terrance D. Savitsky Office of Survey Methods Research FCSM - 2018 March 7-9, 2018 1 / 21

More information

INLA: Integrated Nested Laplace Approximations

INLA: Integrated Nested Laplace Approximations INLA: Integrated Nested Laplace Approximations John Paige Statistics Department University of Washington October 10, 2017 1 The problem Markov Chain Monte Carlo (MCMC) takes too long in many settings.

More information

Approximate Bayesian Computation. Alireza Shafaei - April 2016

Approximate Bayesian Computation. Alireza Shafaei - April 2016 Approximate Bayesian Computation Alireza Shafaei - April 2016 The Problem Given a dataset, we are interested in. The Problem Given a dataset, we are interested in. The Problem Given a dataset, we are interested

More information

Advanced Statistical Computing Week 2: Monte Carlo Study of Statistical Procedures

Advanced Statistical Computing Week 2: Monte Carlo Study of Statistical Procedures Advanced Statistical Computing Week 2: Monte Carlo Study of Statistical Procedures Aad van der Vaart Fall 2012 Contents Sampling distribution Estimators Tests Computing a p-value Permutation Tests 2 Sampling

More information

Homework #4 Programming Assignment Due: 11:59 pm, November 4, 2018

Homework #4 Programming Assignment Due: 11:59 pm, November 4, 2018 CSCI 567, Fall 18 Haipeng Luo Homework #4 Programming Assignment Due: 11:59 pm, ovember 4, 2018 General instructions Your repository will have now a directory P4/. Please do not change the name of this

More information

The gbev Package. August 19, 2006

The gbev Package. August 19, 2006 The gbev Package August 19, 2006 Version 0.1 Date 2006-08-10 Title Gradient Boosted Regression Trees with Errors-in-Variables Author Joe Sexton Maintainer Joe Sexton

More information

This is a good time to refresh your memory on double-integration. We will be using this skill in the upcoming lectures.

This is a good time to refresh your memory on double-integration. We will be using this skill in the upcoming lectures. Chapter 5: JOINT PROBABILITY DISTRIBUTIONS Part 1: Sections 5-1.1 to 5-1.4 For both discrete and continuous random variables we will discuss the following... Joint Distributions (for two or more r.v. s)

More information