MCV172, HW#3. Oren Freifeld May 6, 2017

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

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

Statistics 352: Spatial statistics. Jonathan Taylor. Department of Statistics. Models for discrete data. Stanford University.

CSC 2541: Bayesian Methods for Machine Learning

Propp-Wilson Algorithm (and sampling the Ising model)

Computational statistics

Intelligent Systems:

Computer Vision Group Prof. Daniel Cremers. 14. Sampling Methods

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

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm

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

Stat 516, Homework 1

Markov Chain Monte Carlo

Sampling Methods (11/30/04)

The Metropolis Algorithm

Bayesian Inference and MCMC

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

Monte Carlo Methods. Leon Gu CSD, CMU

The Particle Filter. PD Dr. Rudolph Triebel Computer Vision Group. Machine Learning for Computer Vision

Default Priors and Effcient Posterior Computation in Bayesian

Markov Random Fields and Bayesian Image Analysis. Wei Liu Advisor: Tom Fletcher

Lecture 6: Markov Chain Monte Carlo

6 Markov Chain Monte Carlo (MCMC)

Markov Random Fields

One-Parameter Processes, Usually Functions of Time

Machine Learning for Data Science (CS4786) Lecture 24

16 : Approximate Inference: Markov Chain Monte Carlo

Module 6: Introduction to Gibbs Sampling. Rebecca C. Steorts

Lecture 4 Towards Deep Learning

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

Markov Chain Monte Carlo Inference. Siamak Ravanbakhsh Winter 2018

Introduction to Machine Learning CMU-10701

Markov chain Monte Carlo Lecture 9

Probabilistic Graphical Models Lecture Notes Fall 2009

Markov Chains. As part of Interdisciplinary Mathematical Modeling, By Warren Weckesser Copyright c 2006.

A quick introduction to Markov chains and Markov chain Monte Carlo (revised version)

28 : Approximate Inference - Distributed MCMC

STA 4273H: Statistical Machine Learning

CPSC 540: Machine Learning

Exponential families also behave nicely under conditioning. Specifically, suppose we write η = (η 1, η 2 ) R k R p k so that

MCMC algorithms for fitting Bayesian models

ST 740: Markov Chain Monte Carlo

Bayesian Methods for Machine Learning

Polynomial accelerated MCMC... and other sampling algorithms inspired by computational optimization

Markov Chain Monte Carlo (MCMC)

NORGES TEKNISK-NATURVITENSKAPELIGE UNIVERSITET PREPRINT STATISTICS NO. 13/1999

Markov Chain Monte Carlo Lecture 6

Introduction to Bayesian methods in inverse problems

Variational Inference (11/04/13)

Bayesian Methods with Monte Carlo Markov Chains II

Bayesian Networks Inference with Probabilistic Graphical Models

Monte Carlo integration

Theory of Stochastic Processes 8. Markov chain Monte Carlo

DAG models and Markov Chain Monte Carlo methods a short overview

Homework set 2 - Solutions

Advanced Sampling Algorithms

Principles of Bayesian Inference

Oberwolfach workshop on Combinatorics and Probability

Robust Monte Carlo Methods for Sequential Planning and Decision Making

MCMC and Gibbs Sampling. Kayhan Batmanghelich

Sample-based UQ via Computational Linear Algebra (not MCMC) Colin Fox Al Parker, John Bardsley March 2012

Markov Chain Monte Carlo Methods

Gibbs Sampling in Linear Models #1

Convex Optimization CMU-10725

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

Advanced Introduction to Machine Learning

Quantifying Uncertainty

Computer Vision Group Prof. Daniel Cremers. 11. Sampling Methods

MCMC: Markov Chain Monte Carlo

Lecture 8: The Metropolis-Hastings Algorithm

Monte Carlo methods for sampling-based Stochastic Optimization

9 Forward-backward algorithm, sum-product on factor graphs

Introduction to Mobile Robotics Bayes Filter Particle Filter and Monte Carlo Localization

Rare Event Sampling using Multicanonical Monte Carlo

Deblurring Jupiter (sampling in GLIP faster than regularized inversion) Colin Fox Richard A. Norton, J.

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

11. Learning graphical models

Lecture 15: MCMC Sanjeev Arora Elad Hazan. COS 402 Machine Learning and Artificial Intelligence Fall 2016

MCMC and Gibbs Sampling. Sargur Srihari

ECO 513 Fall 2008 C.Sims KALMAN FILTER. s t = As t 1 + ε t Measurement equation : y t = Hs t + ν t. u t = r t. u 0 0 t 1 + y t = [ H I ] u t.

Markov chain Monte Carlo

Robert Collins CSE586, PSU Intro to Sampling Methods

Learning the hyper-parameters. Luca Martino

17 : Markov Chain Monte Carlo

Module 7: Introduction to Gibbs Sampling. Rebecca C. Steorts

The Ising model and Markov chain Monte Carlo

Probabilistic Machine Learning

Graphical Models and Kernel Methods

Statistical Sequence Recognition and Training: An Introduction to HMMs

Markov and Gibbs Random Fields

Markov Networks.

SAMPLING ALGORITHMS. In general. Inference in Bayesian models

MCMC Methods: Gibbs and Metropolis

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

Supplementary Note on Bayesian analysis

Markov Chains and MCMC

MSc MT15. Further Statistical Methods: MCMC. Lecture 5-6: Markov chains; Metropolis Hastings MCMC. Notes and Practicals available at

Stat 535 C - Statistical Computing & Monte Carlo Methods. Arnaud Doucet.

10708 Graphical Models: Homework 2

MCMC Sampling for Bayesian Inference using L1-type Priors

Transcription:

MCV72, HW#3 Oren Freifeld May 6, 207 Contents Gibbs Sampling in the Ising Model. Estimation: Comparisons with the Nearly-exact Values...... 2.2 Image Restoration.......................... 4 Gibbs Sampling in the Ising Model We will test the Gibbs sampler by computing ectations and comparing with the exact results which we obtained using dynamic programming from HW#2. We will also pretend that the Ising model is a good model for images, and study image restoration from Ising-model samples corrupted by noise. Remark Before you start coding a single line in this assignment, do yourself a favor and read the entire document. Reminder: Gibbs Sampling from the Ising-Model Prior Recall the Ising-model prior, px, is px x s and that px s s x = px s, s x p s x = x s Thus, = px p s x = x s s t Z x s x s = Z > 0, s t x s s t x s x s +. 2 px s s x = px s x ηs 3

and px s = s x = px s = s x = xt t:t ηs t:t ηs xt+ xt t:t ηs t:t ηs xt+ t:t ηs xt t:t ηs xt So sampling from this conditional distribution is just flipping a coin, where the bias on the coin is affected by the states of the neighbors of x s. Reminder: Gibbs Sampling from the Ising-Model Posterior, Assuming Gaussian IID Additive Noise Under this assumption, letting x denote the sample from the Ising-model prior and y denote the noise, px y s t x s 2σ 2 y s x s 2 5 s and. 4 px s s x, y = px s, s x y = px y p s x y p s x y s t x s 2σ = 2 s y s x s 2 x s s t x s 2σ 2 s y s x s 2 x s t:t ηs 2σ 2 y s x s 2 6 Thus, px s s x, y = px s x ηs, y = px s x ηs, y s 7 and px s = s x, y px s = s x, y t:t ηs 2σ 2 y s 2 t:t ηs 2σ 2 y s + 2 8. 9 Again, the sampling is nothing more than flipping a coin, where here the bias on the coin is affected by both i the states of the neighbors of x s and ii y s, the measurement associated with x s.. Estimation: Comparisons with the Nearly-exact Values In HW #2, we used exact sampling to estimate E X, X 2,2 and E X, X 8,8 2

through their empirical ectations, Ê X, X 2,2 0000 x, nx 2,2 n 0 0000 n= Ê X, X 8,8 0000 x, nx 8,8 n 0000 where x, x2,..., x0000 were 0,000 exact samples from the Ising model. We refer to these ectations as nearly-exact for the following reason: the term exact stems from the fact the samples were obtained using exact sampling, while the nearly qualifier is added since an empirical ectation, i.e., the average over the samples i.e., AKA the sample mean is a random quantity which, by the Law of Large Numbers, converges to the true ectation as the number of samples tends to infinity. Now, in the current HW assignment, instead of using exact sampling, we will produce the samples using MCMC, particularly the Gibbs-sampling method. Computer Exercise Build a Gibbs sampler for the 8 8 Ising model at temperatures {,.5, 2}. Compute the empirical ectations of n= E X, X 2,2 and E X, X 8,8 2 using two different methods; see below. Compare the estimates to the nearlyexact values computed in the previous HW assignment; see the table below. Programming Note: A convenient way to handle boundaries is to embed the n n lattice in the interior of an n + 2 n + 2 lattice whose boundary values are set to zero, and then visit only the n n interior sites of the larger lattice. Method. Independent Samples. At each temperature, draw 0,000 approximated samples from the Ising-model prior, px x s, 3 using the Gibbs sampler. For each sample, initiate the Gibbs sampler at a random configuration, and update sites in deterministic, raster-scan, order fixed site-visitation schedule. The sample is the obtained configuration after 25 passes through the entire graph i.e., after 25 sweeps where each sweep involves 8 8 = 64 single-site updates. Putting it differently, you are asked to run 0,000 such Markov Chains, where each chain has 25 64 iterations. Let the obtained 0,000 approximated samples be denoted by x,..., x0000. Your estimates are then 0000 x, nx 2,2 n and 0000 n= s t 0000 0000 n= x, nx 8,8 n. 4 Method 2. Ergodicity. Beginning with a random configuration, run the Gibbs sampler for 25,000 sweeps of the lattice i.e., a single Markov Chain 3

temperature Ê X, X 2,2 Ê X, X 8,8 0.95 0.9.5 0.77 0.55 2 your result from HW2 your result from HW2 Table : Expectations estimated from exact samples using dynamic programming of 25,000 64 iterations. Use the empirical averages of x, x 2,2 and x, x 8,8 over all but the first 00 sweeps i.e., following a socalled burn-in period of 00 sweeps, use the 24,900 configurations obtained at the end of each of the remaining sweeps to compute the empirical averages. Remark 2 Note that for computing the average of, say, such 24,900 quantities, you do not need to store 24,900 values in memory. In effect, suppose you have a sequence of N values, denoted by z, z 2,..., z N and you want to compute N N n= z i. Then you can discard each z i once you iteratively update the current estimate of the mean: µ [] = z 5 µ [n] = n z m = n z m + z n 6 n n = n m= n n n m= z m m= + z n = n µ[n ] + z n n n 2, 3,..., N. 7 Exercise Compare the results obtained from the two methods, and compare the results to the values from exact sampling. Speculate about the reasons for any substantial discrepancies..2 Image Restoration These eriments are to be performed on a 00 00 lattice. Computer Exercise 2 At each of the three temperatures {,.5, 2}:. Using Gibbs sampling, generate a single 00 00 sample, x, from the 00 00 Ising model using 50 raster-scan sweeps. 2. Add to the sample an array of 00 00 Gaussian noise values, sampled IID from N 0, 2 2 = 4. We denote this noise array by η. Here is one way to achieve this in Python: eta = 2*np.random.standard_normalsize=00,00 y = x + eta 4

3. Using Gibbs sampling, generate a sample from the posterior distribution of the uncorrupted sample given the corrupted sample, again using 50 sweeps. x px y, 8 4. For comparison, compute the ICM Iterated Conditional Mode restoration: visit sites, in raster order, replacing at each site the current spin by its most-likely value of the two possibilities, ±, under the posterior distribution and conditioned on the four neighbors: where x new s = arg max px s s x, y 9 x s {,} px s s x, y = px s x ηs, y = px s x ηs, y s. 20 This greedy algorithm will converge within a few raster cycles. 5. Display all four images from the previous 4 steps on a single plot. see the subplot and imshow commands. 5