Monte Carlo Methods & Variance Reduction

Monte Carlo replaces an expectation or integral with random draws and reports the sampling error of the resulting estimator. Importance sampling, control variates, stratification, Markov-chain Monte Carlo, and Gibbs updates change how evidence is obtained; diagnostics must distinguish target invariance from finite-run mixing and effective information.

Monte Carlo methods estimate a quantity by sampling rather than exhaustive summation or deterministic quadrature. They are especially valuable when dimension makes a regular grid impossible: doubling resolution in each of dd dimensions multiplies grid work by 2d2^d, whereas ordinary Monte Carlo's root-mean-square error remains proportional to N−1/2N^{-1/2} under finite variance. That rate is slow, but it does not deteriorate directly with dimension.

A two-coordinate Gibbs sampling sweep Starting at one point in a correlated target, Gibbs sampling draws the horizontal coordinate conditional on the vertical coordinate and then the vertical coordinate conditional on the new horizontal coordinate. One Gibbs sweep follows conditional slices x y 1. draw x′ | y 2. draw y′ | x′
A Gibbs sweep is a composition of conditional draws. Each coordinate update leaves the joint target invariant; practical accuracy still depends on whether repeated sweeps move across the target's relevant geometry.

Estimation begins with an expectation #

Suppose the target is

I=Ep[f(X)]=∫f(x)p(x) dx.I=\mathbb E_p[f(X)]=\int f(x)p(x)\,dx.

For independent draws Xi∼pX_i\sim p,

I^N=1N∑i=1Nf(Xi)\hat I_N=\frac1N\sum_{i=1}^N f(X_i)

is unbiased, with variance Varp[f(X)]/N\mathop{\mathrm{Var}}_p[f(X)]/N. An estimated Monte Carlo standard error (MCSE) is

MCSE^=sfN,\widehat{\mathop{\mathrm{MCSE}}} =\frac{s_f}{\sqrt N},

where sfs_f is the sample standard deviation of the evaluated quantity. Reporting only I^N\hat I_N hides numerical uncertainty from finite simulation.

To reduce independent-sampling error by a factor of ten requires roughly one hundred times as many draws. Better algorithms therefore try to reduce variance per unit cost, not merely increase NN.

Variance reduction uses structure #

Antithetic and stratified sampling #

Antithetic draws couple samples so their errors tend to cancel; for a monotone function under a uniform input, pairing UU with 1−U1-U is a common example. Stratification divides the input space into regions and samples each, preventing random omission of important strata. Both require a structure that actually correlates with ff.

Control variates #

If g(X)g(X) has known expectation μg\mu_g, estimate

I=E[f(X)−β(g(X)−μg)].I=\mathbb E[f(X)-\beta(g(X)-\mu_g)].

The optimal scalar β=Cov(f,g)/Var(g)\beta=\mathop{\mathrm{Cov}}(f,g)/\mathop{\mathrm{Var}}(g) reduces variance when gg tracks ff. Estimating β\beta from the same data needs care in finite samples.

Importance sampling #

When direct draws from pp are hard but a proposal qq is easy,

I=Eq[f(X)p(X)q(X)].I=\mathbb E_q\left[f(X)\frac{p(X)}{q(X)}\right].

The proposal must cover every region where f(x)p(x)f(x)p(x) matters. A few extreme weights create a formally correct but practically unstable estimator. Inspect normalized weights, tail behavior, and effective sample size; a large raw sample does not compensate for missing support.

MCMC trades independence for accessible transitions #

Markov-chain Monte Carlo constructs a transition kernel whose invariant distribution is the target π\pi. After initialization and finite transitions, states are correlated and may still reflect the start. For a scalar estimand, the variance of the sample mean is approximately

Var(fˉ)≈Varπ(f)Neff,\mathop{\mathrm{Var}}(\bar f)\approx \frac{\mathop{\mathrm{Var}}_\pi(f)}{N_{\mathrm{eff}}},

where NeffN_{\mathrm{eff}} accounts for autocorrelation. ESS and MCSE belong to a particular parameter or function; there is no single chain-wide sample quality number.

Run multiple dispersed chains. Rank-normalized split-R^\hat R compares between- and within-chain behavior and can reveal nonstationarity or scale disagreement; bulk and tail ESS quantify different regions. Values near one for R^\hat R are necessary evidence, not proof that all modes were found. A shared initialization in one mode can make every chain agree on the wrong region.

Warmup adapts and moves chains toward typical regions; discarding a finite prefix cannot guarantee convergence. Thinning usually throws away information and should be used for storage constraints, not as a cure for autocorrelation. A better transition kernel or longer run is the remedy.

Gibbs sampling uses full conditional distributions #

For a joint target π(x1,…,xd)\pi(x_1,\ldots,x_d), a systematic Gibbs sweep draws

x1′∼π(x1∣x2,…,xd),x2′∼π(x2∣x1′,x3,…,xd), ⋮xd′∼π(xd∣x1′,…,xd−1′).\begin{aligned} x_1'&\sim\pi(x_1\mid x_2,\ldots,x_d),\\ x_2'&\sim\pi(x_2\mid x_1',x_3,\ldots,x_d),\\ &\ \vdots\\ x_d'&\sim\pi(x_d\mid x_1',\ldots,x_{d-1}'). \end{aligned}

Each update uses the newest available coordinates. To see why one coordinate update preserves the joint target, suppose (X,Y)∼π(X,Y)\sim\pi. Keep YY and redraw X′∼π(x∣Y)X'\sim\pi(x\mid Y). Then

Pr⁡(X′∈A,Y∈B)=∫Bπ(A∣y)πY(dy)=π(A×B).\Pr(X'\in A,Y\in B) =\int_B\pi(A\mid y)\pi_Y(dy) =\pi(A\times B).

Composing invariant coordinate kernels yields an invariant sweep. This explains correctness at stationarity; it does not establish irreducibility or fast mixing from an arbitrary start.

Block Gibbs samples several strongly coupled variables jointly. Random-scan Gibbs selects coordinates randomly; systematic scan applies a fixed order. Both can preserve the target under appropriate conditions, but they can have different reversibility and convergence rates.

Worked bivariate-normal Gibbs sampler #

For a standard bivariate normal with correlation ρ\rho,

[XY]∼N([00],[1ρρ1]),\begin{bmatrix}X\\Y\end{bmatrix} \sim\mathcal N\left( \begin{bmatrix}0\\0\end{bmatrix}, \begin{bmatrix}1&\rho\\\rho&1\end{bmatrix} \right),

the full conditionals are

X∣Y=y∼N(ρy,1−ρ2),Y∣X=x∼N(ρx,1−ρ2).X\mid Y=y\sim\mathcal N(\rho y,1-\rho^2), \qquad Y\mid X=x\sim\mathcal N(\rho x,1-\rho^2).

When ∣ρ∣|\rho| is small, alternating draws move freely. As ∣ρ∣→1|\rho|\to1, the conditional variance shrinks and the chain advances in small correlated steps along a narrow diagonal. The target is unchanged, but ESS per sweep collapses. Joint rotation, blocking, or a different sampler addresses geometry that more iterations only brute-force.

Gibbs in Boltzmann machines #

An RBM's bipartite graph makes hidden units independent given the visible layer and visible units independent given the hidden layer. One block Gibbs step can therefore update an entire layer in parallel. Contrastive divergence begins near data and uses only a short chain, so its negative sample is intentionally not a converged independent draw from the model. That bias is an optimization approximation and must not be described as exact maximum likelihood.

A reproducible Monte Carlo report #

Record the target, estimand, sampler and transition parameters, initialization, warmup/adaptation, saved draws, independent chains, random seeds, ESS, MCSE, R^\hat R, trace/autocorrelation checks, and any divergences or mode-specific behavior. For importance sampling, add proposal support and weight diagnostics. For Gibbs, add scan order, blocks, and conditional parameterization.

Simulation produces an estimate plus simulation error. A method is not validated by producing many numbers; it is validated by showing that its draws explore the intended target and that the remaining Monte Carlo uncertainty is small enough for the decision.

Sources

  1. bookAdvanced Simulation Methods: Markov Chains and Gibbs Sampling
  2. docsStan Reference Manual: Posterior Analysis
  3. docsCmdStan Guide: MCMC Sampling

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close