Conditional Monte Carlo Created 2026-10-06 Updated 2026-10-14
Replacing a simulated quantity by preserves its expectation and reduces variance by the law of total variance. This is Rao-Blackwellization. For a random sum, conditioning on the count and all but one summand replaces an event indicator by a cumulative distribution function evaluation. The resulting estimator needs that conditional expectation to be computable.
For independent means and , the first mean's conditional precision is and conditional precision-weighted mean is ; replace by for the second mean. With its conditional law is . The discrete split has conditional probabilities proportional to . These full conditional distributions give a Gibbs sampler including . Averaging the sampled indicators of that configuration estimates its probability; averaging its conditional probabilities gives an estimate by Rao-Blackwellization.
Lehmann–Scheffé theorem Created 2026-10-07 Updated 2026-10-14
An unbiased estimator that is a function of a complete sufficient statistic is the unique uniformly minimum-variance unbiased estimator, up to almost sure equality. Rao-Blackwellization supplies variance reduction, and completeness supplies uniqueness. The theorem applies to a conditional statistical experiment as well, when unbiasedness, sufficiency and completeness are all evaluated under that conditional family.
The Metropolis–Hastings algorithm proposes and moves from the current state with acceptance probability
On rejection it retains . The target need only be known up to its normalizing constant, but it must define a proper probability distribution. The accepted off-diagonal probability flow is
which is symmetric in and proves detailed balance. This permits considerable flexibility in proposals, including joint moves when a posterior distribution has strongly correlated parameters, but requires proposal tuning and can waste computation on rejections.
A Gibbs sampler instead updates a coordinate or block from its exact full conditional distribution, holding the other coordinates fixed. This is a special Metropolis–Hastings algorithm update with acceptance probability one: the joint density factors into the unchanged marginal density and the proposed conditional density, which cancel in the acceptance ratio. The coordinate update preserves the target; composing such updates therefore preserves it too, although an entire deterministic sweep need not itself be reversible.
Use Gibbs sampling when the conditional laws are easy to simulate and suitably chosen blocks mix well. Scalar updates can mix poorly under strong posterior distribution correlation, whereas a blocked Gibbs sampler can alleviate that dependence. Prefer a flexible Metropolis proposal when conditional draws are difficult or a well-tuned joint proposal is more effective. Variations include random or systematic coordinate scans, random-walk Metropolis algorithms, independence proposals, and using Metropolis updates for difficult blocks inside a Gibbs scheme. Both methods generate dependent draws; usable long-run estimates require an appropriate irreducible, aperiodic chain and assessment of mixing, not merely a formal update rule.
For the change-point calculation, put and
Multiplication of the Gaussian likelihood function by the specified prior distribution gives the formal posterior distribution kernel, with respect to and counting measure on ,
There is an empty component under an improper prior at . The sum is independent of , whose prior distribution is flat on all of . For every fixed finite and , the kernel is a strictly positive constant in , hence
The configuration has positive prior probability . Integrating over, for example, a bounded interval of and already makes the joint normalization infinite. Thus the printed prior distribution does not produce a posterior probability distribution. This failure is present for every data set, not just for a special arrangement of observations.
The formal full conditionals expose exactly where the requested sampler breaks. For , completing the two mean squares gives
The variance kernel is that of when , and the discrete conditional probabilities are proportional to . At the conditional kernel for is constant and cannot be normalized; it is not a normal distribution with an infinite variance. Therefore no valid Gibbs sampler, and no value of , exists for the model as printed. A chain that simply substitutes an arbitrary distribution for this missing conditional would be sampling a different model.
Here is a fully specified proper-prior repair retaining the no-change configuration. Choose fixed hyperparameters
independently, with . Its Gaussian change-point posterior with proper priors is
It is normalizable even for degenerate data: the likelihood function is at most , and its integral against the variance prior distribution is bounded by
The normal mean priors integrate to one, and the normalizing constant is positive. This proves posterior propriety for the repaired model.
Completing the conditional squares gives the Gaussian change-point Gibbs updates. Define
The four updates are
At , , giving its proper prior distribution unchanged. Starting from any finite means, positive variance and allowed , cycle through these four updates using the latest values. The sum-of-squares terms can be evaluated from cumulative data sums; normalize the discrete log weights after subtracting their maximum to avoid numerical underflow. The proper positive conditionals allow movement among all split values and throughout the continuous parameter support.
Under this specified repair, is the posterior probability of no change within the observed sequence: all data points belong to the first mean regime. For retained draws after initialization has ceased to affect the estimates, its Markov chain Monte Carlo estimator is
Alternatively average the displayed conditional probability of at the sampled continuous parameters, giving an estimate by Rao-Blackwellization. Autocorrelation must be accounted for in its Monte Carlo uncertainty. These are probabilities and estimators for the explicitly repaired model; the original unnormalizable kernel supplies neither.
Both alternatives can be made explicit. For a conditional bias-corrected normal mean estimate, let be the observed pooled estimate and , with . Invert its conditional mean:
This can be solved by bracketing or by Newton iteration . Since ,
The variance of a standard normal conditional on exceeding is , strictly between zero and one. Positivity follows from nondegeneracy; the upper bound follows because the conditional mean exceeds the truncation threshold . Hence , so the equation has at most one root. As , ; as , the truncated stage-1 mean approaches its threshold and , so a root exists for every finite . Equivalently, differentiating the conditional likelihood divides the ordinary likelihood by and gives the same score equation. This conditional-likelihood correction is not exactly conditionally unbiased merely because it inverts a mean.
For an illustration, take , , and . The equation is . Since and , the corrected estimate lies between zero and ; numerical solution gives , below the selected ordinary estimate.
For the uniform minimum variance conditionally unbiased estimator, put , , and . The fresh estimate is conditionally unbiased because it is independent of continuation. Let
Before selection, conditional Gaussian calculations give . Conditional on as well, this normal variable is truncated below , so
Using , Rao-Blackwellization therefore gives
Its conditional expectation is , and its conditional variance cannot exceed that of . To justify uniform minimum variance, the joint conditional density of is a base density on multiplied by . Thus is a complete sufficient statistic in the one-parameter conditional exponential family, whose natural parameter ranges over an open real interval. The Lehmann–Scheffé theorem proves the claim. The orthogonal pooled arm-average statistic is independent of the entire difference process and carries the nuisance common mean. Together with , it gives a complete sufficient statistic in the selected two-parameter normal family, with an open natural-parameter space. Thus allowing that nuisance statistic does not improve the conditional unbiased estimate of the difference. For the same illustration, , and give . It differs from the conditional-likelihood estimate because exact conditional unbiasedness is a different criterion.
The printed identity needs an expectation on its right-hand side. For fixed , condition on and use independence of :
The expression inside this expectation is generally random and cannot equal the unconditional probability by itself.
For each independent Monte Carlo method replicate, draw from its given distribution. If , draw independent -variables, form and set . For the empty sum is . If may equal zero, use when , since . The law of total expectation gives
Since , the estimator has statistical consistency by the strong law of large numbers. It is the conditional Monte Carlo estimator obtained by Rao-Blackwellization of the direct indicator , and the law of total variance gives .
This version assumes that the cumulative distribution function can be evaluated. An easy sampler alone does not automatically supply an easy cumulative distribution function evaluation. If only sampling is available, use the direct indicator estimator, or replace each conditional cumulative distribution function by the average of several independent indicators ; the nested version remains an unbiased estimator. With such inner draws its variance per outer replicate is .
I would first collapse the duration noises as in part (c), then use self-normalized importance sampling on the two shared parameters. Draw independent , give each the importance weight , and return
This is likelihood weighting: the observations affect the weights rather than forcing repeated simulation of twenty latent inequalities. Integrating out both the constraints' auxiliary randomness and the future Boolean query is Rao-Blackwellization; at fixed parameters it removes randomness without changing the relevant conditional expectations.
The weights and weighted queries lie in , and the evidence is positive. The strong law of large numbers therefore makes the numerator and denominator averages converge to their corresponding integrals, proving almost sure convergence of their ratio to part (d). The finite- ratio is generally biased; the assertion concerns consistency rather than a finite-sample unbiased estimator. Use logarithms of importance weights to avoid numerical underflow:
def weighted_answer(n, rng):
    if n <= 0:
        raise ValueError("n must be positive")
    samples = []
    for _ in range(n):
        mu = rng.uniform(0.0, 60.0)
        sigma = rng.uniform(1.0, 20.0)
        samples.append((journey_loglik(mu, sigma),
                        math.exp(5.0 * normal_logcdf((mu - 30.0) / sigma))))
    offset = max(logw for logw, h in samples)
    if not math.isfinite(offset):
        raise ArithmeticError("all weights underflowed")
    scaled = [(math.exp(logw - offset), h) for logw, h in samples]
    den = math.fsum(w for w, h in scaled)
    answer = math.fsum(w * h for w, h in scaled) / den
    ess = den * den / math.fsum(w * w for w, h in scaled)
    return answer, ess
The returned effective sample size of importance sampling is a concentration diagnostic, not a proof of accuracy. Repeat runs and inspect the weights. If the prior is much broader than the posterior, improve the proposal with the corresponding importance sampling density correction, or use the Metropolis–Hastings algorithm targeting . Because this particular collapsed problem is only two-dimensional, deterministic numerical integration is also an excellent independent accuracy check; it was used for the figure and numerical illustration. Straight rejection of the original traces is correct but wastes most proposals here.
A UMVCUE has minimum conditional variance among all estimators unbiased in the selected experiment for every parameter. For independent Gaussian stage estimates with information , continuation , total information and pooled estimate , Rao-Blackwellization of the fresh estimate gives , where . The conditional family has complete sufficient statistic , so the Lehmann–Scheffé theorem establishes the optimum. A conditional-likelihood bias correction does not automatically have this unbiasedness property.