technique

Accept-reject sampling

Build any custom probability distribution by repeatedly drawing a candidate value and a second qualifying value, keeping the candidate only if it passes.

Also called: accept-reject algorithm · custom probability distribution

What it is

Accept-reject sampling turns two random draws into a decision: keep the first number, or throw it away and try again. The source behind this entry names it “accept-reject algorithm” and files it as “a type of Monte Carlo method”.

How it works

Draw a first random value. Draw a second value, and use it — in the source’s own words — “to decide whether to use that first number or throw it away and pick another.” If it’s rejected, the described procedure is to “go back to step 1 and start over.”

Go deeper

The quoted material comes from Nature of Code, at the URL the evidence records.


Revision 2 · 1 source · Something wrong? Tell us.