Applied class 9 Problem Set
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Applied class 9 Problem Set
1. Consider an Ising model for a 10 by 10 lattice that assigns a probability
e_βH(σ)
Z(β)
to each σ e (-1, 1}100 , where
H(σ) := - σvσw .
(v,w}eE
Implement a Gibbs sampler for this model. Use your Gibbs sampler to estimate the correlation between the spins of various pairs of nodes, for multiple values of the inverse temperature β . Comment on how the value of β influences the behaviour of this system.
2. Consider the first-order autoregressive process
xt = φxt_1 + νt
for t = 2, . . . , n, where IφI < 1, νt are iid N(0, 1) and x1 ~ N(0, ) (which is the stationary distribution of the process).
Show that the joint density of _ is
p(_) = p(x1 )p(x2 Ix1 ) . . . p(xnIxn_1 )
= IQI1/2 exp(- _T Q_)
where the precision matrix is tridiagonal
、│
. │
. │
.. .│
with zeros off the diagonals.
3. The zero-inflated Poisson model is defined as follows:
p ~ U(0, 1)
λIp ~ Γ(a, b)
riIp, λ ~ Ber(p)
xiIr, λ ~ Pois(λri)
where a, b are known. The posterior distribution for p, λ and r has density given by Bayes rule as
f(r, λ, pI_) x ba λa_1 e λ i rip iri (1 - p)n_ iriλ i xi n ri(x)i
Γ(a) i=1 xi! .
(a) Simulate drawing 1000 integers from a zero-inflated Poisson data model with p = 0.1 and λ = 10. (b) Show that the conditional distributions for p, λ and ri are
pIλ, r, _ ~ Beta(1 + ri, n + 1 - ri)
i i
λIp, r, _ ~ Γ(a + xi, b + ri)
i i
riIλ, p, _ ~ Ber ╱ 、
(c) Implement a Gibbs sampler to sample p and λ from an appropriate posterior distribution. Use the sample to construct approximate density plots of the posterior marginals for p and λ .
4. Implement a generic slice sampler for an arbitrary target distribution with density p(北) defined on an interval [a, b]. Use it to sample from a distribution with density p(北) x 北2 sin (22 π北) on the interval [-1, 1] and to estimate the variance of such a distribution.
2023-06-03