---
title: "Rejection Sampling"
type: concept
related: [Failure Distribution]
source: https://www.jemoka.com/posts/kbhrejection_sampling/
confidence: high
status: active
---

steps (coda) for some unnormalized target failure density, which is our target (and nominal trajectory \(p\qty(\tau)\)):
\begin{equation} \bar{p} \qty(\tau \mid \tau \not \in \psi) = \mathbb{1}\qty {\tau \not \in \psi} p\qty(\tau) \end{equation}
sample \(\tau \sim q\qty(\cdot)\) where \(q\) is the proposal distribution where you start generating your samples; you want this to be as close as you can to the target failure distribution.
reject if \(cq\qty(\tau) r &gt; \bar{p}\qty(\tau)\) first, choose a normalizing constant \(c\) which makes
\begin{equation} \bar{p} \qty(\tau) \leq c q\qty(\tau) \end{equation}
true. This allows us to rescale our proposal distribution to be at least as big as our target distribution.
In particular keep a sample of \(\tau\) if:
\begin{equation} r &lt; \frac{\bar{p}\qty(\tau)}{cq\qty(\tau)} \end{equation}
where \(c\) is a constant that makes the inequality true; \(\bar{p}\) is the not normalized density (a la a Failure Distribution).
drawbacks selecting an appropriate proposal distribution \(\tau \sim q\qty(\cdot)\) is hard selecting an appropriate value for \(c\) 109&rsquo;s definition Sample a ton; perform factor conditioning; then count the observation you&rsquo;d like.
by rejecting those who don&rsquo;t match
