Agenda - Stanford University

26
Stats 318: Lecture # 10 Agenda: I Gibbs sampling I Examples

Transcript of Agenda - Stanford University

Page 1: Agenda - Stanford University

Stats 318: Lecture # 10

Agenda:

I Gibbs sampling

I Examples

Page 2: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 3: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 4: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 5: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 6: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 7: Agenda - Stanford University

Gibbs sampling

Special case of Metropolis-Hastings algorithm over product space

I Each x ∈ X has n components: x = (x1, . . . , xn)

e.g. Ising model with x = {xv} xv ∈ {−1,+1}

I Gibbs sampler updates one component at a time

e.g. (1) Choose j ∈ {1, . . . , n} randomly

(2) Sample X ′j from π(Xj | X−j)

(3) Update (Xj , X−j)←− (X ′j , X−j)

Page 8: Agenda - Stanford University

Formulation as a Metropolis iteration

I Proposal distribution

Q(x, y) =

1nπ(yi | y−i) yi 6= xi, y−i = x−i

0 otherwise and y 6= x

1−∑y:y 6=x

Q(y, x) y = x

I Observe reversibility: yi 6= xi, y−i = x−i

π(x)Q(x, y) =1

nπ(x−i)π(xi | x−i)π(yi | y−i)

=1

nπ(y−i)π(xi | x−i)π(yi | y−i) = π(y)Q(y, x)

I Acceptance probability h(u) = min(u, 1) =⇒ accept with probability 1!

I Consequence: chain converges to equilibrium

Page 9: Agenda - Stanford University

Formulation as a Metropolis iteration

I Proposal distribution

Q(x, y) =

1nπ(yi | y−i) yi 6= xi, y−i = x−i

0 otherwise and y 6= x

1−∑y:y 6=x

Q(y, x) y = x

I Observe reversibility: yi 6= xi, y−i = x−i

π(x)Q(x, y) =1

nπ(x−i)π(xi | x−i)π(yi | y−i)

=1

nπ(y−i)π(xi | x−i)π(yi | y−i) = π(y)Q(y, x)

I Acceptance probability h(u) = min(u, 1) =⇒ accept with probability 1!

I Consequence: chain converges to equilibrium

Page 10: Agenda - Stanford University

Formulation as a Metropolis iteration

I Proposal distribution

Q(x, y) =

1nπ(yi | y−i) yi 6= xi, y−i = x−i

0 otherwise and y 6= x

1−∑y:y 6=x

Q(y, x) y = x

I Observe reversibility: yi 6= xi, y−i = x−i

π(x)Q(x, y) =1

nπ(x−i)π(xi | x−i)π(yi | y−i)

=1

nπ(y−i)π(xi | x−i)π(yi | y−i) = π(y)Q(y, x)

I Acceptance probability h(u) = min(u, 1) =⇒ accept with probability 1!

I Consequence: chain converges to equilibrium

Page 11: Agenda - Stanford University

Formulation as a Metropolis iteration

I Proposal distribution

Q(x, y) =

1nπ(yi | y−i) yi 6= xi, y−i = x−i

0 otherwise and y 6= x

1−∑y:y 6=x

Q(y, x) y = x

I Observe reversibility: yi 6= xi, y−i = x−i

π(x)Q(x, y) =1

nπ(x−i)π(xi | x−i)π(yi | y−i)

=1

nπ(y−i)π(xi | x−i)π(yi | y−i) = π(y)Q(y, x)

I Acceptance probability h(u) = min(u, 1) =⇒ accept with probability 1!

I Consequence: chain converges to equilibrium

Page 12: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 13: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 14: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 15: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 16: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 17: Agenda - Stanford University

Variation

Can also cycle through components in some fixed order; e.g. 1, 2, . . . , n

I P (i) transition matrix for updating component i

I Above transition

P =1

n

n∑i=1

P (i)

I Sequential transition

P ′ = P (1) . . . P (n)

I For each i ∈ {1, . . . , n}

πP (i) = π =⇒ πP = π & πP ′ = π

I π unique equilibrium for both chains

Page 18: Agenda - Stanford University

Example: Ising model

π(x) =1

Ze−βE(x) E(x) = −

∑v ∼ v′

xvxv′

P(Xv = 1 | X−v = x−v)

P(Xv = −1 | X−v = x−v)= e2βgv gv =

∑v′:v′∼v

xv′

∴ P(Xv = 1 | X−v = x−v) =1

1 + e−2βgv

Page 19: Agenda - Stanford University

Example: Ising model

π(x) =1

Ze−βE(x) E(x) = −

∑v ∼ v′

xvxv′

P(Xv = 1 | X−v = x−v)

P(Xv = −1 | X−v = x−v)= e2βgv gv =

∑v′:v′∼v

xv′

∴ P(Xv = 1 | X−v = x−v) =1

1 + e−2βgv

Page 20: Agenda - Stanford University

Example: Ising model

π(x) =1

Ze−βE(x) E(x) = −

∑v ∼ v′

xvxv′

P(Xv = 1 | X−v = x−v)

P(Xv = −1 | X−v = x−v)= e2βgv gv =

∑v′:v′∼v

xv′

∴ P(Xv = 1 | X−v = x−v) =1

1 + e−2βgv

Page 21: Agenda - Stanford University

Example: Ising model

π(x) =1

Ze−βE(x) E(x) = −

∑v ∼ v′

xvxv′

P(Xv = 1 | X−v = x−v)

P(Xv = −1 | X−v = x−v)= e2βgv gv =

∑v′:v′∼v

xv′

∴ P(Xv = 1 | X−v = x−v) =1

1 + e−2βgv

Page 22: Agenda - Stanford University

Gibbs sampler for Ising model

I Initialize X0

I Repeat

• Pick location v at random

• Select U ∼ U [0, 1]

• If U < (1 + e−2βgv )−1, Xv ←− +1else Xv ←− −1

Page 23: Agenda - Stanford University

Gibbs sampler for Ising model

I Initialize X0

I Repeat

• Pick location v at random

• Select U ∼ U [0, 1]

• If U < (1 + e−2βgv )−1, Xv ←− +1else Xv ←− −1

Page 24: Agenda - Stanford University

Gibbs sampler for Ising model

I Initialize X0

I Repeat

• Pick location v at random

• Select U ∼ U [0, 1]

• If U < (1 + e−2βgv )−1, Xv ←− +1else Xv ←− −1

Page 25: Agenda - Stanford University

Gibbs sampler for Ising model

I Initialize X0

I Repeat

• Pick location v at random

• Select U ∼ U [0, 1]

• If U < (1 + e−2βgv )−1, Xv ←− +1else Xv ←− −1

Page 26: Agenda - Stanford University

Gibbs sampler for Ising model

I Initialize X0

I Repeat

• Pick location v at random

• Select U ∼ U [0, 1]

• If U < (1 + e−2βgv )−1, Xv ←− +1else Xv ←− −1