Q59. Gibbs sampling with a weighted count
Topic: Markov chains, Gibbs sampling, and Metropolis–Hastings · more questions on this topic
‹ Q52 Question 6 ›
[10 marks]
Let X\in\{0,1,\ldots,8\} and \theta\in(0,1) have joint probability mass/density function \pi(x,\theta)\propto \binom8x3^x\theta^{x+1}(1-\theta)^{10-x}, \qquad x=0,1,\ldots,8,\quad0<\theta<1.
(a) Find and identify the full conditional distribution X\mid\theta, including its parameters. [3 marks]
(b) Find and identify the full conditional distribution \theta\mid X=x, including its parameters. [3 marks]
(c) Hence write pseudocode for a Gibbs sampler that generates a Markov chain with equilibrium distribution \pi(x,\theta). [3 marks]
(d) Explain why Gibbs sampling does not require an acceptance–rejection step. [1 mark]
Definitions. A full conditional is proportional to the joint as a function of the variable being updated, with the other variable fixed. For x=0,\ldots,n, the Binomial kernel can be written \binom nx\{p/(1-p)\}^x. The Beta kernel is \theta^{a-1}(1-\theta)^{b-1} on (0,1), with a,b>0. Here n=8, and (t) labels a complete sequential Gibbs sweep.
(a) Full conditional of X. For fixed \theta\in(0,1), the marginal density \pi(\theta) does not depend on x, so \pi(x\mid\theta)=\frac{\pi(x,\theta)}{\pi(\theta)} \propto\binom8x3^x\theta^{x+1}(1-\theta)^{10-x}. Use \theta^{x+1}=\theta\theta^x and (1-\theta)^{10-x}=(1-\theta)^{10}(1-\theta)^{-x} to obtain \begin{aligned} \pi(x\mid\theta) &\propto\theta(1-\theta)^{10}\binom8x \left(\frac{3\theta}{1-\theta}\right)^x\\ &\propto\binom8x\left(\frac{3\theta}{1-\theta}\right)^x, \qquad x=0,\ldots,8. \end{aligned} Only the factor \theta(1-\theta)^{10} was dropped: it is constant in x. In contrast, 3^x depends on x and must be retained.
A \operatorname{Binomial}(8,p) probability mass function satisfies \binom8x p^x(1-p)^{8-x} =(1-p)^8\binom8x\left(\frac p{1-p}\right)^x \propto\binom8x\left(\frac p{1-p}\right)^x. Match the odds and solve for p: \begin{aligned} \frac p{1-p}&=\frac{3\theta}{1-\theta},\\ p(1-\theta)&=3\theta(1-p),\\ p-p\theta&=3\theta-3\theta p,\\ p(1+2\theta)&=3\theta. \end{aligned} Therefore \boxed{X\mid\theta\sim \operatorname{Binomial}\!\left(8,\frac{3\theta}{1+2\theta}\right), \qquad X\in\{0,\ldots,8\}.} For 0<\theta<1, the success probability lies strictly between zero and one. The factor 3^x multiplies the Binomial odds by three; it does not simply replace the success probability by 3\theta.
(b) Full conditional of \theta. Now hold x fixed. Both \binom8x and 3^x are constants in \theta, so \pi(\theta\mid x)\propto\pi(x,\theta) \propto\theta^{x+1}(1-\theta)^{10-x},\qquad0<\theta<1. The \operatorname{Beta}(a,b) kernel is \theta^{a-1}(1-\theta)^{b-1}. Matching exponents gives a-1=x+1\ \Longrightarrow\ a=x+2,\qquad b-1=10-x\ \Longrightarrow\ b=11-x. Thus \boxed{\theta\mid X=x\sim\operatorname{Beta}(x+2,11-x), \qquad0<\theta<1.} Both shape parameters are positive for every x\in\{0,\ldots,8\}. Here 3^x can be dropped because the conditioning variable x is fixed.
(c) Gibbs sampler. Choose any valid initial state x^{(0)}\in\{0,\ldots,8\},\qquad\theta^{(0)}\in(0,1), for example (x^{(0)},\theta^{(0)})=(0,1/2). For t=1,\ldots,T:
1. Update X using the previous value of \theta: X^{(t)}\sim\operatorname{Binomial}\!\left( 8,\frac{3\theta^{(t-1)}}{1+2\theta^{(t-1)}}\right).
2. Update \theta using the newly generated X: \theta^{(t)}\sim \operatorname{Beta}\!\left(X^{(t)}+2,11-X^{(t)}\right).
3. Store the completed pair (X^{(t)},\theta^{(t)}).
Use fresh random numbers for each conditional draw. Step 2 conditions on X^{(t)}, not X^{(t-1)}.
Each full-conditional update leaves the joint target invariant, and so does their composition. Both conditionals are positive throughout their respective supports, allowing the chain to move throughout the target support. The resulting Gibbs chain converges to \pi(x,\theta) from a valid starting state. Allow for convergence before using the output for target-distribution summaries.
Equilibrium does not mean independence: successive pairs generally remain dependent because the next X is drawn using the preceding \theta. This is a Markov-chain sampler, not a sequence of independent draws from the joint distribution.
(d) Why no acceptance–rejection step? Each update draws directly from the exact full conditional. It can be viewed as a Metropolis–Hastings update whose proposal is that full conditional, making the acceptance probability one.
For example, when updating X while holding \theta fixed, propose x' from q(x'\mid x,\theta)=\pi(x'\mid\theta). Since \pi(x,\theta)=\pi(\theta)\pi(x\mid\theta), the acceptance ratio is \begin{aligned} R &=\frac{\pi(x',\theta)\pi(x\mid\theta)} {\pi(x,\theta)\pi(x'\mid\theta)}\\ &=\frac{\pi(\theta)\pi(x'\mid\theta)\pi(x\mid\theta)} {\pi(\theta)\pi(x\mid\theta)\pi(x'\mid\theta)} =1. \end{aligned} The same cancellation holds for the \theta update. Hence \alpha=\min\{1,R\}=1: every Gibbs update is accepted, so no separate Metropolis accept/reject decision is required.
Key result. The same joint distribution produces different conditional kernels because a different variable is held fixed. Retain 3^x when updating X; drop it when updating \theta. Always use the latest available conditioning values in a sequential Gibbs sweep.