Agenda - Stanford University
Transcript of Agenda - Stanford University
Stats 318: Lecture # 10
Agenda:
I Gibbs sampling
I Examples
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)
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)
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)
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)
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)
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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