Solution
ID: past-exam-of-the-msc-in-advanced-computer-science-course-of-the-university-of-oxford/2021/bayesian-statistical-probabilistic-programming/1/a/solution
Past exam of the MSc in advanced computer science course of the University of Oxford 2021 Bayesian statistical probabilistic programming 1 a Solution by
Codex 0 2026-10-25
Assume , and work on the support . In rejection sampling, choose a normalized proposal probability mass function and a known finite constant satisfying everywhere. Draw independent random variables and , accepting when . The joint probability of proposing and accepting is , so the overall acceptance probability is and the accepted value has probability mass function . Fresh trials therefore produce independent and identically distributed random variables with the desired probability distribution. For a fixed positive number of accepted values, the sample average is an unbiased estimator of the expectation when that expectation is finite. Its variance is if the second moment is finite. Finding a valid envelope can be difficult, and a small acceptance probability makes the method expensive.
For the Metropolis–Hastings algorithm, choose a proposal transition matrix and, at the current state , propose . Accept with the Metropolis–Hastings acceptance probabilityA proposal outside is rejected; an impossible proposal need not be assigned a ratio. Otherwise remain at . This constructs a Markov chain satisfying detailed balance with , without computing or a global envelope. Estimate the expectation by averaging over iterations, including repeated states after rejections. Keeping only accepted jumps generally changes the stationary distribution of the recorded process.
The Metropolis–Hastings algorithm produces dependent samples, so the variance of its average includes autocovariances; starting outside stationarity can also cause finite-run bias. With Markov chain irreducibility, suitable recurrence and an integrable , the countable-state Markov chain ergodic theorem gives consistency. Aperiodicity is additionally needed for the usual convergence of one-time probability distributions. In contrast, accepted rejection sampling values need no initial transient. Neither method is universally faster: envelope rejection competes with the proposal quality and mixing time of the Markov chain. Nonnegativity of alone does not guarantee a finite expectation or variance.
New to topics? Read the docs here!