Consider independent rejection sampling trials with proposal density , accepted-value density , acceptance probability and rejection probability . Splitting the proposal law by its accept/reject outcome gives , where is the rejected-proposal distribution.
If an algorithm permits 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 failures has probability and gives the conditional law ; every successful stopping trial gives law . Hence the forced return introduces bias unless , and its contribution decays geometrically with the cap. Conditional on success before any specified trial, the output still has law , since accepted value and successful-trial index are independent.
Stopping after a fixed number of rejection sampling proposals preserves the target law of accepted labels, conditional on the number accepted. Stopping instead after a fixed amount of elapsed computing time can change the finite-sample law if processing costs depend on the proposed state. The deadline may censor precisely the expensive states.
For an exact counterexample, let both target and proposal be uniform on two states, so every proposal is accepted. Let processing cost be one time unit for the first state and two for the second. Stop between one and two units and retain only finished proposals. Conditional on obtaining an output, the first state is the only possible value, despite its target probability being one half. This proves that a runtime cutoff need not be an unbiased stopping rule for the realized finite output. It does not imply asymptotic bias of the indefinitely growing completed sequence; it identifies a finite-horizon censoring effect.
Write . Against an exponential distribution proposal of mean , the chi-squared distribution density has envelope constant . The density ratio divided by is . Thus generate and accept when for independent uniform distributions. The inequality validates the acceptance probability. The accepted probability density function is the target because rejection sampling weights the proposal by its target-to-envelope ratio.
Log-concave probability density Created 2026-10-05 Updated 2026-10-06
A probability density is log-concave when its logarithm is a concave function on its support. Tangent lines to a differentiable concave log density lie above its graph, giving exponential envelopes for rejection sampling.
For rejection sampling with acceptance probability , , the accepted count in trials has binomial distribution, mean and variance . To obtain at least acceptances with approximate probability , use the standard normal distribution quantile . The central limit theorem without continuity correction gives . Solving this quadratic inequality in gives the displayed threshold, rounded upward. It exceeds the average stopping cost because it allows for fluctuations in the accepted count. For , the count is deterministic and exactly. Exact coverage uses the binomial distribution tail rather than the approximation.
Optimal geometric envelope for a Poisson distribution Created 2026-10-25 Updated 2026-10-31
For a Poisson distribution target of mean and a geometric distribution proposal with probability mass function on the nonnegative integers, the tight rejection sampling envelope is
Successive target-to-proposal ratios have ratio , proving this maximizing index. The function is the maximum of the convex functions . Within a branch its derivative is .
Writing , the optimum is , and the success parameter is . For , is a branch boundary; the left and right derivatives are nonpositive and nonnegative respectively. For , the active branch has a zero derivative at , including a tie at the upper endpoint. Convexity proves global optimality. The minimum expected proposal count is ; no claim about machine-specific instruction costs is implied.
A trial of Amy's rejection sampling uses exactly fair Bernoulli trials. Exactly of the equally likely binary sequences have heads, so the acceptance probability is
Independent retries make the number of trials a geometric random variable on with expectation . The total number of coin tosses is , so
Using Stirling's approximation, the central binomial coefficient satisfies
Consequently
The rejection sampling output is uniform among the balanced binary sequences: they have equal probability on every trial, and conditioning on acceptance preserves that equality. For , the empty output needs zero tosses; the formula above concerns .
Independently generate uniform on and uniform on , using the bounds above. Accept the proposal if
otherwise generate a fresh pair. On acceptance return . The bounding rectangle contains the entire ratio region: , and lies between the extrema of . Conditioning a uniform rectangle point on acceptance makes it uniform on , so the preceding marginal distribution calculation proves that the returned value has the desired Laplace distribution.
For this target , so the region has area two. The rejection sampling acceptance probability is
Endpoints have zero probability and can be excluded to avoid divisions by zero in implementation.
For any measurable set , integrating the joint acceptance event in rejection sampling gives
Setting equal to the whole support yields . Thus
To verify repeated attempts directly, the probability that the first accepted observation falls in is
With finite , eventual acceptance has probability one. Applying the same argument after each success proves that the retained sequence consists of independent draws from the target.
Assume the target probability density function is supported where the proposal probability density function is positive and that the envelope constant is finite. Any satisfies , and integration gives . For each attempt draw independently and . Accept if ; otherwise discard it and repeat. Independent attempts give independent accepted values. A finite pre-generated list of independent proposal draws can be screened with independent uniforms in the same way, though the number retained is random. If , this fixed-envelope rejection sampling method cannot be used with that proposal.
Use the joint prior density as the proposal for rejection sampling. Since the Poisson probability lies in , the following algorithm is valid:
  • Draw from the proper prior distribution .
  • Independently draw from the exponential distributions with rates , for , and calculate .
  • Draw uniformly on , independently of all previous draws. Retain if ; otherwise restart.
The joint density of a proposed pair together with its acceptance event is . Its integral is , so conditioning on acceptance gives precisely , the desired posterior density. Repeating independent proposal trials until each acceptance produces independent posterior observations. This is Bayesian rejection sampling for a segregating-site count.
An equivalent implementation simulates and accepts exactly when . Its acceptance probability is the same Poisson mass. Propose from the joint prior and accept according to the exact observed-count likelihood. No approximation to the posterior distribution is involved in the accepted draws.
After the top card is fixed, precisely three of the remaining fifty-one cards have the same rank. Thus a fresh uniformly shuffled deck has matching probability
In each independent round, the algorithm repeats with probability and stops with probability . A match always stops. Summing the probabilities over the possible number of repeated rounds gives
For the stopping probability per round is at least , so termination is almost sure.
Permutation of the thirteen rank labels preserves both the uniform shuffle and the stopping rule. The two marginal distributions are consequently uniform:
To establish independence, it is necessary to check the joint probability distribution, not just these marginals. For a specified rank , the fresh-shuffle diagonal probability is . For different specified ranks , it is . Reweight by the acceptance probability and sum over repeated rounds to obtain
The diagonal must equal for independence, forcing and therefore
At this value the off-diagonal expression is also , proving sufficiency for every ordered pair. This is an example of match-biased reshuffling preserves uniform rank marginals: state-dependent rejection sampling changes dependence even though both individual rank distributions remain uniform.
For rejection sampling, independently generate a proposal with density and a uniform on . Accept if ; otherwise generate a fresh independent pair and repeat. Set the ratio to zero on where necessarily . The envelope condition makes the acceptance threshold at most one.
For any measurable set , a single attempt satisfies
Taking the whole space shows that acceptance has probability . Conditioning on acceptance therefore gives density . Repeating rejected independent attempts preserves that conditional law and terminates almost surely; the number of attempts is geometric with mean .
For fixed proposal density, admissibility requires under the pointwise convention in the question. Since decreases with , the smallest valid envelope gives the greatest acceptance probability:
For densities specified only almost everywhere, replace the supremum by the essential supremum. Integration of the envelope also gives .
Group the two terms containing to obtain the mixture distribution
The first component is a Standard Cauchy distribution. The second is normalized because
For this symmetric component, let . Its density is , and hence its cumulative distribution function and quantile function are
The independent sign is positive or negative with equal probability. For one sample, use the next three independent uniforms in the given sequence and return
The Cauchy branch follows from its quantile function, while the other branch follows from the magnitude law and fair sign just derived. Independence of the branch selection and component draws therefore gives exactly the displayed mixture distribution. Discard the zero-probability endpoint draw to keep the computation finite, and use a fresh block of three uniforms for the next sample. This is the symmetric rational mixture sampler.
One can alternatively use the root solution's rejection sampling with a Standard Cauchy distribution proposal. The density ratio is , bounded by because . Accept the Cauchy draw with probability using a fresh independent uniform.
For define the generalized inverse, or quantile function, by
It is finite because the cumulative distribution function tends to zero and one at the two infinities. Monotonicity and right continuity of give the key equivalence
For the forward implication, choose points in the defining set approaching its infimum from above. Right continuity gives , and then monotonicity gives whenever . The reverse implication follows immediately because then belongs to the defining set. Consequently, for a continuous uniform distribution draw ,
This proves inverse transform sampling for discontinuous as well as continuous distribution functions.
There is a minor endpoint defect in the printed codomain. The true quantile endpoint at probability one is , which equals for an unbounded-above normal distribution. Thus it need not be real at one. Use the extended-real value there, or assign an arbitrary finite value at this single probability level. Since , either choice gives the same sampled distribution; the latter supplies a real-valued version on all of . The endpoint has no effect on the inverse-transform law.
For rejection sampling, choose a proposal probability density function that can be sampled and a finite constant with wherever the target has positive mass. Generate independent pairs , with of density and uniform. Accept if ; otherwise discard the pair and repeat with fresh independent draws. At points where both densities vanish the acceptance rule may be defined arbitrarily. For any measurable set ,
Thus one trial accepts with probability , and the conditional density given acceptance is . More explicitly, summing over the index of the first accepted proposal gives
The probability of never accepting is zero, since , and the expected number of proposals is . The algorithm terminates almost surely and samples the target density exactly.
The first algorithm uses independent normal distributions: generate with law and return
For example, the Box-Muller transform generates two such normal variates from independent uniforms:
To verify this, has density and is an independent uniform angle. Converting the resulting polar density to Cartesian coordinates gives , which factors into two independent normal distributions. Independent pairs therefore give the required sum, discarding a spare coordinate when is odd. Its moment-generating function is , that of the chi-squared distribution.
A genuinely different algorithm uses exponential-envelope rejection sampling for a chi-squared variable. Put . The target and proposal probability density functions are
For , differentiating gives , so the maximum is at . The envelope constant and normalized density ratio are
They remain valid at , where and . Repeatedly draw fresh independent , put , and accept when
The right side is nonpositive by , so this is a legitimate acceptance probability. The joint probability of proposing and accepting in is ; conditional on acceptance the density is exactly . This proves the rejection sampling algorithm, rather than only identifying the target law.
For I prefer the second method: it reduces to a single exponential draw with no rejection. The first method is simple and attractive when normal draws are already available or is small. For larger , the second method avoids generating normals: its acceptance probability is , asymptotic to by Stirling's formula. Its expected number of proposals grows like , rather than the linear number of normal draws in the first method. Both are exact ideal-uniform algorithms; actual runtime also depends on the implementation.
The region usually has a curved boundary, so sampling uniformly inside it directly is inconvenient. Rejection sampling replaces it by an easily sampled envelope, usually a rectangle. Choose finite bounds with
Then up to null boundaries. A general rectangle algorithm uses only independent uniform deviates: draw on , set , , and return if ; otherwise repeat. If a numerical generator returns , discard that draw before division. No knowledge of is required to run the method. Its acceptance rate is the ratio of the two areas:
More generally the same area ratio applies to any finite-area envelope sampled uniformly. A change in the proportionality constant of scales both ratio coordinates and their areas consistently.
Finite rectangle bounds are a real condition, not a consequence of integrability alone. For instance is integrable, but is unbounded. A finite-area envelope for a ratio-of-uniforms region gives a general extension: choose a finite-area open envelope containing , decompose it up to null boundaries into countably many disjoint rectangles, and select a rectangle with probability proportional to its area using a uniform draw and cumulative probabilities. Use two more uniforms to sample within it, then apply the same acceptance test. This samples the envelope uniformly and has acceptance . Such envelopes exist for every finite-area measurable ; obtaining usable bounds or an effective rectangle decomposition is density-specific. The finite-rectangle version above is the usual practical implementation.
Choose a proposal probability density function and a finite envelope constant such that wherever the target has positive density. A rejection sampling trial draws and, independently, ; accept when
otherwise repeat with fresh independent draws. For any measurable set ,
In particular , so the conditional accepted density is . More explicitly, summing over the possible first accepted trial gives
Thus the algorithm terminates almost surely and its output has exactly the requested law.
The envelope constant satisfies and is the expected number of proposal trials for one output, by the geometric distribution of the waiting time. This is the quantity often called the rejection rate . The actual probability of rejecting a particular proposal is , and the expected number of rejections before one acceptance is ; these conventions should not be conflated.
To generate a standard normal distribution, first generate its absolute value, whose half-normal distribution density is
With the given exponential distribution proposal, the density ratio is
Its maximum is at , hence the normal rejection sampling with an exponential envelope constant is
Draw and a fresh uniform ; accept when . An accepted has density . Independently choose a sign, positive or negative with probability , and output with that sign and magnitude . On either half-line its density is , proving the normal output law.
To optimize the rejection rate, differentiate
Its derivative is , negative before one and positive after one; equivalently its second derivative is . Thus
The rejection probability is consequently about .
To use only uniforms, apply inverse transform sampling: for an independent ,
has survival probability for . Use a second independent uniform for acceptance, and, after acceptance, a third independent uniform to choose the sign. Repeat with fresh uniforms after any rejection. No exponential generator is then needed.
Label batches before consulting the random-number table, so their labels are independent of the test results. A uniformly random permutation of , restricted to a smaller label set, induces a uniformly random ordering of that set. This provides a simple rejection-and-restriction scheme:
  • For A, label each day's six batches . Use a fresh permutation, discard labels , and test the first remaining batch. Repeat independently on each working day. Each daily batch has inclusion probability , and five batches are tested per week.
  • For B, label the fifteen weekly morning batches . Discard label 16 from a fresh permutation and choose the first three remaining labels. Use an independent permutation for the afternoon stratum. Every three-element subset within a stratum is equally likely, and each batch has inclusion probability . Six batches are tested per week.
  • For C, label the weekdays . Keep the first label in this range from a fresh permutation and test all six batches on that day. Repeat independently each week. Every day, and hence every batch, has inclusion probability ; six batches are tested per week.
With independent random digits instead, rejection sampling gives the same uniform choices: for A keep only digits ; for C keep only . For B, use uniform two-digit numbers, retain labels , and reject repeats within a three-batch sample. Taking residues modulo six or fifteen from a table whose range is not divisible by that number would give unequal probabilities. These are respectively day-stratified simple random sampling, morning/afternoon stratified sampling, and a one-day design using cluster sampling. The printed word “rest” for A is interpreted as “test”, consistently with the surveillance task. If it instead meant leaving one batch untested, choose that omitted batch uniformly and test the other five; this alternative would test 25 batches per week, with inclusion probability , and has a different testing budget.
For each proposal , independently draw and accept it when
The ratio is at most one, as required. For any measurable set ,
so the acceptance probability is and the conditional distribution of an accepted proposal has density . Repeating independent trials until acceptance therefore gives an exact draw from , and repeating the whole procedure gives iid target draws. This proves rejection sampling.
The number of proposals for one successful draw is geometric with mean . Thus is also the expected proposal cost of this exact simulation method.