On , the exponential proposal is the proper density ; its integral is . The word “improper” in the question is therefore not applicable on its stated positive support.
The target-to-proposal ratio is
Its maximum occurs at , so the smallest valid envelope constant is
One implementation draws and accepts it when , for independent random variables with the uniform distribution on . Accepted observations have the positive half-normal density by the usual rejection sampling calculation.
Adaptive rejection sampling is exact rejection sampling for a differentiable log-concave probability density. Given interior evaluation points , construct the upper envelope
where is the unnormalized target probability density function. The concave function lies below all its tangent lines, so . Interpolation between adjacent evaluation points gives a lower envelope there, allowing a squeeze test. The normalized upper envelope is a piecewise exponential proposal distribution.
Draw and an independent from the uniform distribution, and accept when . A squeeze test can establish acceptance without evaluating . Otherwise evaluate and, whenever it is evaluated, add to the envelope's points. Repeat until acceptance. On each linear piece , its integral is on , with value when . These integrals select a piece; inverse transform sampling samples within it.
Here, with and , the log-posterior on has
Choose evaluation points strictly inside , avoiding any endpoint singularities of the logarithm. Every finite set of tangent lines gives a finite upper-envelope integral on this bounded interval; slope conditions needed for unbounded supports are unnecessary. When the posterior distribution is simply the uniform distribution and may be sampled directly.
For any fixed envelope, proposal times acceptance is proportional to . Conditional on all past evaluations and rejections, the next accepted value therefore has the same normalized posterior density. To see that adaptation does not spoil this, at every attempted draw its accepted mass is a scalar times that fixed posterior density; summing over possible rejection histories preserves it. The acceptance probability stays bounded below by its positive initial-envelope value because insertion only lowers the upper envelope. Thus acceptance occurs almost surely. With fresh independent randomness, successive accepted values are exact independent samples from the posterior distribution, even when the envelope is retained and improved between them.
Given the parameters and , the coordinates are conditionally independent. Write , , and let denote the observed count. Their full conditional distributions have scalar densities
Each is proper: the binomial distribution likelihood factor is bounded, and the remaining factor is a proper normal distribution density.
One completely specified exact algorithm is rejection sampling from . Define
For ,
for or , take , and for take . Propose and accept with probability , repeating until acceptance. The accepted density is proportional to the proposal times , exactly . Its acceptance probability is positive, so it terminates almost surely, although it can be inefficient.
An efficient exact alternative is adaptive rejection sampling. The log density has
Thus it is a log-concave probability density. Choose one tangent point with positive derivative in the left tail and one with negative derivative in the right tail; these exist because the Gaussian term dominates there. Their tangent upper hull gives an integrable piecewise exponential rejection envelope. Sample that envelope, accept using the target-to-envelope ratio, and add evaluated points to improve it. Concavity guarantees the upper bound, so accepted samples remain exact. Sample each coordinate independently by either method; a finite number of Metropolis steps would not provide the requested exact draws.
In one proposal of rejection sampling, the probability of both proposing a value in and accepting it is
Integrating shows that the acceptance probability is . Conditional on acceptance, the density of the proposed value is therefore
Each unsuccessful proposal restarts independently, so the eventual output has the same conditional density:
Assume , and work on the support . In rejection sampling, choose a normalized proposal probability mass function and a known finite constant satisfying everywhere. Draw independent random variables and , accepting when . The joint probability of proposing and accepting is , so the overall acceptance probability is and the accepted value has probability mass function . Fresh trials therefore produce independent and identically distributed random variables with the desired probability distribution. For a fixed positive number of accepted values, the sample average is an unbiased estimator of the expectation when that expectation is finite. Its variance is if the second moment is finite. Finding a valid envelope can be difficult, and a small acceptance probability makes the method expensive.
For the Metropolis–Hastings algorithm, choose a proposal transition matrix and, at the current state , propose . Accept with the Metropolis–Hastings acceptance probability
A proposal outside is rejected; an impossible proposal need not be assigned a ratio. Otherwise remain at . This constructs a Markov chain satisfying detailed balance with , without computing or a global envelope. Estimate the expectation by averaging over iterations, including repeated states after rejections. Keeping only accepted jumps generally changes the stationary distribution of the recorded process.
The Metropolis–Hastings algorithm produces dependent samples, so the variance of its average includes autocovariances; starting outside stationarity can also cause finite-run bias. With Markov chain irreducibility, suitable recurrence and an integrable , the countable-state Markov chain ergodic theorem gives consistency. Aperiodicity is additionally needed for the usual convergence of one-time probability distributions. In contrast, accepted rejection sampling values need no initial transient. Neither method is universally faster: envelope rejection competes with the proposal quality and mixing time of the Markov chain. Nonnegativity of alone does not guarantee a finite expectation or variance.
Variational inference replaces exact Bayesian inference by an optimization problem over a tractable family . A guide program samples from this approximating family. Optimizing an evidence lower bound is equivalent to minimizing . Its appeal is that a fitted approximation can be cheap to sample and may scale well when an exact posterior distribution is inaccessible. A restricted family, such as mean-field variational inference, can miss dependence or entire modes; a local optimum can add further error. More optimization cannot remove approximation error caused by an inadequate family.
Monte Carlo method inference instead estimates posterior expectations using simulated values or weighted values. Examples include rejection sampling, importance sampling and Markov chain Monte Carlo. Under their respective support and convergence assumptions, increasing computation can yield consistent estimates without choosing a finite-dimensional posterior family. Their uncertainty includes simulation error; an inefficient proposal or slow mixing time can make that error large. Markov chain Monte Carlo additionally requires convergence and dependence diagnostics.
The central trade-off is optimization within an approximate family versus simulation under a target probability distribution. It is not an absolute distinction between deterministic and random computation: variational inference often uses Monte Carlo method estimates of its gradient, while Monte Carlo method inference may use fitted proposals. Neither method automatically guarantees accurate uncertainty estimates or superiority at a fixed computational budget.
Treat each observed arrival label as a constraint on an unobserved walking duration. Departures are treated as fixed design information. Writing for the minutes available until work starts, the derived late-label thresholds have frequencies ; the early-label thresholds have frequencies . These are censoring thresholds, not measured journey times. A late label means , and an early label means ; equality has probability zero under the continuous model.
The paper specifies no prior distribution. One explicit proper model is
with independent priors; all times are in minutes. These ranges are a transparent modelling choice, not information deduced from the observations. In particular, this is a prior on the standard deviation , not a uniform prior on the variance . The normal distribution permits negative durations; it is the mathematical approximation requested here, rather than a claim that such durations are physically possible. A truncated model would be a different model.
The following Python implements hard conditioning by rejection sampling. None marks a rejected trace; an accepted Boolean answers whether all five future arrivals are late. The same parameters are shared across past and future days.
import math
import random

LATE = {20: 1, 21: 3, 25: 3, 27: 1, 32: 2}
EARLY = {29: 1, 34: 1, 36: 3, 37: 1, 38: 1, 39: 1, 43: 1, 44: 1}
RECORDS = [(c, True) for c, n in LATE.items() for _ in range(n)]
RECORDS += [(c, False) for c, n in EARLY.items() for _ in range(n)]

def journey_trace(rng):
    mu = rng.uniform(0.0, 60.0)
    sigma = rng.uniform(1.0, 20.0)
    # Twenty latent past durations and five future durations.
    past = [rng.gauss(mu, sigma) for _ in RECORDS]
    future = [rng.gauss(mu, sigma) for _ in range(5)]
    if not all(t > c if late else t < c
               for t, (c, late) in zip(past, RECORDS)):
        return None
    return all(t > 30.0 for t in future)

def accepted_average(trace, n, rng):
    if n <= 0:
        raise ValueError("n must be positive")
    successes = accepted = 0
    while accepted < n:
        result = trace(rng)
        if result is not None:
            accepted += 1
            successes += int(result)
    return successes / n
For example, accepted_average(journey_trace, n, random.Random(2021)) estimates the desired conditional probability from accepted traces. Accepting False is essential: treating a false answer as a rejected trace would condition on the desired conclusion. The model deliberately emphasizes clear semantics; rejection can be inefficient because all twenty past-label constraints must hold together.
Draw independent uniforms on , put , and accept if ; otherwise repeat independently. This is rejection sampling from the uniform proposal . Its accepted unnormalized density is , and the acceptance probability is
Dividing by gives the target Wigner semicircle distribution. The number of trials up to and including the first acceptance has a geometric distribution with success probability , so
The expected number of rejected trials alone is .
Write . The two multivariate normal distribution probability density functions have ratio
Here is the Euclidean norm. Consequently the smallest rejection sampling envelope constant, and its acceptance probability, are
The supremum is attained at ; hence no smaller constant can dominate the ratio. Draw and an independent from the uniform distribution on . Accept when
otherwise repeat with fresh independent random variables. One can generate using a random vector with independent standard normal distribution coordinates.
For any measurable set , the joint acceptance probability is . Dividing by proves that the returned random vector has probability density function . The number of proposals has a geometric distribution on the positive integers, with expected value . When , every proposal is accepted.
At equal sample count, rejection sampling eventually has smaller variance for fixed ; at equal expected proposal cost, importance sampling eventually wins. The distinction matters because a sample of the rejection sampling estimator means an accepted draw.
For the importance sampling estimator, all coordinates contribute to the importance weight although only one enters the integrand. The same normal distribution transform as in (c), now with linear coefficient for coordinate one, gives
Both estimators are unbiased estimators of , and
For fixed , the first variance grows exponentially while the second stays constant. This is the benefit of returning exact target draws in rejection sampling. However, obtaining those draws costs proposals each on average.
To compare computational work, multiply each variance by its expected proposal count. For importance sampling that count is ; for rejection sampling it is . The ratio of the resulting cost-normalized variances is
because . Thus importance sampling eventually gives better precision for the same expected number of proposals, assuming comparable work per proposal. This is an asymptotic cost comparison, not a guarantee that a fixed small computing budget produces any accepted draws. Both methods still deteriorate exponentially in this comparison. For they coincide and every proposal is accepted.
Figure 1.
Sample-count and expected-proposal-cost comparisons for the one-coordinate integrand at sigma squared equal to two
. Details.
A practical improvement is to exploit the integrand's one-coordinate structure directly: average for standard normal distribution draws , without generating unused coordinates. The optimal change of proposal distribution in (iii) improves further.
Stop rejection sampling when exactly target draws have been accepted. The total proposal count is a sum of independent waiting times with geometric distribution, equivalently a negative binomial distribution counting trials. Consequently
The accepted-sample Monte Carlo estimator then has the approximate precision from (a)(iii). The displayed proposal cost is an expected value, which need not be an integer. Spending this many proposals in advance does not ensure that target draws will have been accepted.
Integrating the envelope shows . One trial of rejection sampling draws and an independent from the uniform distribution on , and accepts if . Repeat with fresh independent random variables after each rejection. Ratios need only be evaluated where ; the envelope makes the target zero wherever .
For any measurable set , integration of the conditional probability of acceptance gives
Taking the whole domain gives acceptance probability , and dividing gives . Fresh trials therefore supply independent and identically distributed random variables with target probability density function . The corresponding Monte Carlo estimator is
The proposal count up to and including one acceptance has the geometric distribution
For example, the tail-sum formula gives . Thus the expected cost is proposal draws per accepted target draw.
The definition of and (c)(i) give . Nonnegativity of the variance strengthens the lower bound to
In fact the variance of one weighted observation is exactly
It is finite by the envelope. For , the central limit theorem gives approximate two-sided coverage , so the paper's rounded quantile yields
If , the weighted observation equals almost surely, and one draw is sufficient. These are theoretical budgets: and may themselves be unknown and need preliminary estimation in an implementation.
Compare with the average rejection sampling cost . Ignoring integer rounding, importance sampling uses fewer proposal draws at the same approximate precision precisely when
For literal integer budgets, the comparison is . The simpler strict inequality is the intended leading-order condition. The bound alone does not ensure an improvement when ; this is a proposal-budget variance comparison of importance and rejection sampling.
Use the same acceptance indicator functions and set , . The rejection sampling estimator based on these proposals is the mean over the accepted observations:
For , any fixed convention, such as zero, is harmless asymptotically. The are independent and identically distributed random variables with Bernoulli distribution and success probability , so the strong law of large numbers gives almost surely. In particular eventually almost surely. The exact identity
then holds whenever . Wherever , it follows that
A qualification is missing from the printed claim: the quotient must be defined eventually. A convenient sufficient assumption is and . Indeed, another application of the strong law of large numbers gives , ensuring that is eventually nonzero. This proves the stated quotient limit under that assumption.
As printed, the assertion is false as a universally defined quotient. For example, makes both estimates zero for every . Even excluding that example is insufficient: take to be the uniform distribution on , , and for and otherwise. Then is a simple symmetric random walk, which returns to zero infinitely often almost surely, leaving the quotient undefined infinitely often.
With integrability but no assumption , the exact multiplicative identity remains valid, and both estimates converge to almost surely. In particular almost surely. One may alternatively define the quotient's removable cases as ; that explicitly extended quantity always converges to one. These are valid repairs of the source's unrestricted statement.
Probabilistic programming Created 2026-10-24 Updated 2026-10-31
Probabilistic programming expresses a probability model as an executable program with random choices and observations. Executing the generative part induces a probability distribution; observations then restrict or weight executions, and inference computes the resulting conditional distribution. Program syntax and inference algorithm are separate choices: the same model can be evaluated by rejection sampling, importance sampling or Markov chain Monte Carlo.
Ratio-of-uniforms method 2026-10-14
For a nonnegative integrable function with integral , its ratio-of-uniforms region has area . A uniform point in the region transforms under with Jacobian determinant ; integrating over gives density . A rectangle containing the region gives a practical rejection sampling algorithm using only uniform random variables, with acceptance .
Remainder recycling 2026-10-20
A random number generation technique that retains the unused equally likely outcomes after a rejected trial in rejection sampling. Instead of discarding those outcomes, it uses their conditional probability to obtain a new uniform distribution on a finite set for the input state of the next trial.
A lower envelope can save evaluations of an expensive unnormalized target in rejection sampling. Draw with probability density function and an independent uniform distribution value . Accept immediately if . Otherwise draw a fresh independent uniform distribution value and accept if
For a fixed proposal, writing , and gives total acceptance probability . If , the first stage accepts with probability one and the residual test is skipped. Thus the accepted probability density function is , and the overall acceptance probability is . The probability of avoiding a target evaluation on one proposal is .
The displayed mixture distribution combines a Standard Cauchy distribution and a symmetric law whose magnitude has cumulative distribution function for . Use independent uniforms : if , return ; otherwise return a fair independent sign times . The magnitude density is and splitting its mass equally between signs gives . An alternative rejection sampling proposal is standard Cauchy, with envelope constant , because .
The unit-radius Wigner semicircle distribution has the displayed probability density function. Its graph is a rescaled upper semicircle. The area of the unit semicircle is , so the factor normalizes it. Symmetry gives mean zero, and the substitution gives variance .
A scaled radius- version has density on and variance . Rejection sampling from a uniform proposal on accepts a proposed with probability ; its average acceptance probability is . Thus the number of proposals for one output has geometric distribution with expectation . This law also describes the limiting empirical eigenvalue density in standard ensembles of large symmetric random matrices.