Bias from returning a rejected proposal after a rejection-sampling cap (source code)

= Bias from returning a rejected proposal after a rejection-sampling cap
{title2=$f_n=(1-r^n)f+r^n g_R,\qquad g_R=(q-(1-r)f)/r$}

Consider independent <rejection sampling> trials with proposal density $q$, accepted-value density $f$, acceptance probability $a\in(0,1)$ and rejection probability $r=1-a$. Splitting the proposal law by its accept/reject outcome gives $q=af+rg_R$, where $g_R$ is the <rejected-proposal distribution>.

If an algorithm permits $n$ trials, returns the first accepted value when one occurs, and otherwise returns the final rejected proposal, its output density is the displayed mixture. The event of $n$ failures has probability $r^n$ and gives the conditional law $g_R$; every successful stopping trial gives law $f$. Hence the forced return introduces bias unless $g_R=f$, and its contribution decays geometrically with the cap. Conditional on success before any specified trial, the output still has law $f$, since accepted value and successful-trial index are independent.