Docsity

Markov Random Fields and Sampling Techniques: Monte Carlo Markov Chains and Gibbs Sampling, Assignments of Computer Science

Partial preview of the text

Download Markov Random Fields and Sampling Techniques: Monte Carlo Markov Chains and Gibbs Sampling and more Assignments Computer Science in PDF only on Docsity!

Joe Kniss

CS 530

Probabilistic and Geometric Methods Markov Random Fields

Sampling from a distribution

  • Problem 8 on homework:
    • Generate N samples from a distribution.
      1. Generate N samples from Uniform Dist.
      1. Map through inv CDF of desired dist.

Other ways to Sample

  • Discrete PMFs:
    • Make sure # of samples for each bin matches PMF, then shuffle
  • Continuous PDFs?

Rejection Method

    1. determine max prob/density d
    1. determine min-max domain m,M
    1. Draw sample from Uniform: x
    1. Scale & Bias x to [ m,M ]
    1. Draw sample from Uniform: t
    1. Scale t by d: t=t*d
    1. Keep x if t>p(x)

MCMC Example

  • Generate N samples from:

P ( x " [ 0 : 255]) = e # x^^2 /1000^ / $ i^255 = 0 e # i^2 /

MCMC

  • Choose an initial xt
    • According to some “candidate” dist
  • Choose “next” xt+
    • xt jumps to xt+1 according to:

xt + 1 =

xt + 1 P ( xt + 1 ) > P ( xt ) xt + 1 P ( xt + 1 ) / P ( xt ) > rand() Draw new xt + 1 & start over

#^ $

%^ $

MCMC

  • Samples form a markov chain
  • We are sampling this conditional
    • But we never need the inv CDF!
    • Does P(x) need to be “normalized”?
    • Works for complicated PMFs and PDFs

P (xt + 1 | xt ) " min( P ( xt + 1 ) / P ( xt ), 1 )

MCMC

  • What about the multidimensional case?
    • Not so easy to come up with inv CDF!

Gibbs Sampling

  • Conditional distribution:
  • Update each xi independently
  • This is a 1D PMF
  • Maybe you can go back to inv CDF! …

P ( x i^ t^ | x^ ( jt "# i 1))

Convergence, Stopping Criteria

  • The first many samples may not be a good sampling of distribution.
  • For complicated PMFs/PDFs may take some time to “settle down”

Markov Random Fields

  • Remember joint to conditional:

s !

t 1

!

t 2

!

t 3

t 4

!

t 5 t 6 t 7 t 8

P ( xs | xt , t " Ns )

= P P ( x ( sx ,^ tx , tt^ , t "^ " N^ Ns ) s )

Markov Random Fields

  • It can be difficult to manage high- dimensional joint/conditional distributions

s !

t 1

!

t 2

!

t 3

t 4

!

t 5 ! t 6 t 7 t 8

P ( xs | xt 1 , xt 2 , xt 3 , xt 4 , xt 5 , xt 6 , xt 7 , xt 8 )

Gibbs Sampler for MRFs

  • Made easy if we apply the Gibbs method: - Update one site at a time - Pick one site (s) at random - Draw new xs from conditional - … and repeat, repeat, repeat !

P ( xs | xt , t " Ns )

Gibbs Potential

  • Still difficult to deal with conditional:
  • Gibbs potential
    • Compose conditional using “easier” functions ! – Operate on subsets of neighborhood

P ( xs | xt 1 , xt 2 , xt 3 , xt 4 , xt 5 , xt 6 , xt 7 , xt 8 )