liveBook · Manning

Accept/reject algorithm

As explained in Grokking Bayes

An accept-reject algorithm samples candidate outcomes from a proposal process and accepts or rejects them according to a specified rule or probability.

An accept/reject algorithm filters proposed moves. In Metropolis–Hastings, it compares the proposed point’s posterior density with the current point’s density, accepting the move with probability min(1, r); otherwise, it stays put. section 5.6 section 5.7

A Metropolis–Hastings iteration follows this short sequence:

  • Start at a current point in the hypothesis space. section 5.6
  • Draw a nearby proposal from a Normal distribution centered at the current point. section 5.6
  • Compute r as proposed posterior density divided by current posterior density, using unnormalized densities when necessary. section 5.6
  • Accept the proposal according to that probability; rejection records the current point again. section 5.6

A small sampling loop

A Python implementation stores an initial value, proposes Normal steps, evaluates an unnormalized posterior, calculates r, and either records the proposal or repeats the previous sample. Repeated filtering keeps samples concentrated in high-density regions while still allowing exploration elsewhere. section 5.7

How Grokking Bayes covers it

How deep it goes
Explains initialization, proposal, density ratio, probabilistic acceptance, and retention, but defers the mathematical guarantee proof.
Examples
Uses a Beta(4, 3) posterior, an unnormalized Python density function, and a NumPy sampling loop.
What it assumes
Assumes basic posterior-density and probability ideas while building the MCMC procedure through a concrete sampling example.
What you can do after
Apply it via Python and NumPy to generate MCMC samples from a posterior known only up to a constant.
How it connects
Connects MCMC with Metropolis–Hastings, proposal distributions, posterior distributions, and target distributions.

Also explained in

Compare how 2 books explain accept/reject algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Bayes. The section links point to the parts of the book it draws on.