MATH 565 — Fall 2026

Markov Chain Monte Carlo
Owen, Chapters 6, 8, 11, and 15 (selected topics)
Discrepancy: Hickernell, Kirk, Sorokin (2026), Section 5

Assignment 4 due Oct 7

Fred J. Hickernell

October 9, 2026

Course Map

Monte Carlo foundations, methods, and applications
Practice
Probability
Statistics
Analysis
Markov Chain
Monte Carlo
Discrepancy
Measures
Low
Discrepancy
Estimation
Error
Assessment
Statistical
Inference
Bayesian
Computation

\[\begin{gather*} \vZ_i\mid\vX_i\sim\varrho_{\mathrm{prop}}(\cdot\mid\vX_i) \;\xrightarrow{\text{accept or stay}}\;\vX_{i+1}\\ \vX_i\sim\varrho_{\mathrm{tar}}\ \text{at stationarity},\qquad Y_i=f(\vX_i),\quad \mu=\Ex_{\mathrm{tar}}(Y) \end{gather*}\]

From Direct Sampling to Markov Chains

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo
Probability

When direct sampling is difficult

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo
  • Quantile, affine, and exact transport maps
    • Global construction: a map that produces the target distribution
  • Acceptance–rejection
    • Global bound: a proposal envelope valid throughout the target support
  • Markov chain Monte Carlo (MCMC), via Metropolis–Hastings
    • Local decision: density ratios at the current and proposed states
    • No global envelope; proposed moves need not be nearby

From a global sampling construction to a target-preserving transition

Under suitable conditions, the distribution of \(X_i\) approaches the target as \(i\to\infty\)

The Markov property

Monte Carlo foundations, methods, and applications
Probability

Let \(\mathcal X\) be the state space for \(X_0,X_1,\ldots\)

The sequence is a Markov chain when, for every measurable \(A\subseteq\mathcal X\),

\[\begin{equation*} \Prob(X_{i+1}\in A\mid X_i=x_i,\ldots,X_0=x_0)\\ =\Prob(X_{i+1}\in A\mid X_i=x_i) \end{equation*}\]

Where the chain goes next depends only on where it is now, not on how it arrived

We are interested in the asymptotic behavior of \(X_i\)

  • In MCMC, construct the chain so that, under suitable conditions, the distribution of \(X_i\) approaches the target as \(i\to\infty\)

Examples of Markov chains

Monte Carlo foundations, methods, and applications
Probability

Assume \(\epsilon_0,\epsilon_1,\ldots\ \IIDsim\ \Norm(0,1)\)

Markov

\[\begin{align*} X_0&=0,& X_{i+1}&=X_i+\epsilon_i\\ X_0&=0,& X_{i+1}&=i+\epsilon_i \end{align*}\]

The second chain is not time homogeneous: its transition law changes with \(i\)

Not Markov as written

\[ X_0=X_1=0, \qquad X_{i+1}=X_{i-1}+\epsilon_i \]

The augmented state \(\vH_i=(X_{i-1},X_i)\) is Markov because its state retains the needed history

Only the first is a martingale: its expected next value, given the history, equals its current value

Metropolis–Hastings Sampling

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo

The Metropolis–Hastings algorithm

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo

For states in \(\reals^d\), suppose

  • the target has normalized density \(\varrho_{\mathrm{tar}}\), known up to a factor through \(\widetilde\varrho_{\mathrm{tar}}\propto\varrho_{\mathrm{tar}}\)
  • \(\varrho_{\mathrm{prop}}(\vz\mid \vx)\) proposes a new state \(\vz\) from the current state \(\vx\)

Given \(\vX_0\), repeat for \(i=0,\ldots,n-2\):

  1. Generate \(\vZ_i\mid\vX_i\sim\varrho_{\mathrm{prop}}(\cdot\mid \vX_i)\) and \(V_i\sim\Unif[0,1]\), independently of the proposal

  2. Compute

    \[ \alpha(\vX_i,\vZ_i)=\min\!\left\{1, \frac{\widetilde\varrho_{\mathrm{tar}}(\vZ_i)\varrho_{\mathrm{prop}}(\vX_i\mid \vZ_i)} {\widetilde\varrho_{\mathrm{tar}}(\vX_i)\varrho_{\mathrm{prop}}(\vZ_i\mid \vX_i)}\right\} =\min\!\left\{1, \frac{\text{joint density of first $\vZ_i$, then $\vX_i$}} {\text{joint density of first $\vX_i$, then $\vZ_i$}}\right\} \]

  3. Set \(\vX_{i+1}=\vZ_i\) if \(V_i\le\alpha(\vX_i,\vZ_i)\)
    Otherwise set \(\vX_{i+1}=\vX_i\)

Every iteration accepts either the proposal or the current state
Nothing is discarded; use \(Y_i=f(\vX_i)\) for output summaries

Why the acceptance ratio works

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo
Probability

The ratio compares the two directions of a proposed transition:

\[ \frac{\widetilde\varrho_{\mathrm{tar}}(\vZ_i)\varrho_{\mathrm{prop}}(\vX_i\mid \vZ_i)} {\widetilde\varrho_{\mathrm{tar}}(\vX_i)\varrho_{\mathrm{prop}}(\vZ_i\mid \vX_i)} = \frac{\text{target weight at $\vZ_i$}\times\text{return proposal}} {\text{target weight at $\vX_i$}\times\text{forward proposal}} \]

  • Moves toward higher target density are favored
  • Asymmetric proposals are corrected by the proposal-density ratio
  • The unknown factor relating \(\widetilde\varrho_{\mathrm{tar}}\) to the target cancels

Detailed balance preserves the target; convergence from the starting state requires suitable conditions

The Metropolis algorithm

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo

If the proposal is symmetric,

\[ \varrho_{\mathrm{prop}}(\vz\mid \vx) =\varrho_{\mathrm{prop}}(\vx\mid \vz), \]

then the acceptance probability simplifies to

\[ \alpha(\vx,\vz)=\min\!\left\{1, \frac{\widetilde\varrho_{\mathrm{tar}}(\vz)}{\widetilde\varrho_{\mathrm{tar}}(\vx)}\right\} \]

For a random-walk proposal \(\vZ_i=\vX_i+\vepsilon_i\) with symmetric \(\vepsilon_i\):

  • accept every move to a state with at least as much target density
  • accept some downhill moves, which keeps the chain from becoming trapped immediately
  • repeat \(\vX_i\) when a proposal is rejected

Metropolis practice

Monte Carlo foundations, methods, and applications
Practice
Markov Chain
Monte Carlo

Use the uniform numbers in order and choose a random order of the candidate \(z\) values

\(i\) 0 1 2 3 4 5 6 7
\(V_i\) 0.6 0.1 0.3 0.5 0.9 0.2 0.1 0.4
\(z\) \(-1.2\) \(-0.8\) \(-0.5\) \(0.6\) \(1.1\) \(1.4\) \(2.0\) \(2.2\)
\(\widetilde\varrho_{\mathrm{tar}}(z)\) 0.1 0.8 2.0 1.6 0.5 2.6 2.4 1.0

\(\exstar\) Starting at \(x=-1.2\), follow several Metropolis steps and record each accepted or repeated state

A random-walk Metropolis example

Monte Carlo foundations, methods, and applications
Practice
Markov Chain
Monte Carlo

Target a bimodal Gaussian mixture using the symmetric proposal

\[ Z\mid X_i=x\sim\Norm(x,1.4^2) \]

Random-walk Metropolis example with the bimodal target density, sampled-state histogram, and Markov-chain trace

Separated modes can trap a chain

Monte Carlo foundations, methods, and applications
Practice
Markov Chain
Monte Carlo

Same mixture weights and widths; move the means to \(-5\) and \(5\)
Keep \(Z\mid X_i=x\sim\Norm(x,1.4^2)\); start one chain in each mode

Two Metropolis chains started in opposite, widely separated Gaussian modes remain in their starting modes, despite moderate acceptance rates

Acceptance within a mode does not establish exploration of both modes

Tuning and diagnostics

Monte Carlo foundations, methods, and applications
Markov Chain
Monte Carlo
Statistics

MCMC is attractive because it

  • samples from complicated, unnormalized target densities
  • is often straightforward to implement

The proposal and starting point require care:

  • proposals that are too small explore slowly and produce highly dependent samples
  • proposals that are too large have low acceptance rates and many repeats
  • multimodal targets may trap a single chain in one mode

Useful responses include pilot runs, multiple chains, and parallel tempering

MetropolisHastings companion notebook

Diagnose both exploration of the full state space and concentration in high-density regions

Parallel tempering: explore hot, estimate cold

Run replicas with inverse temperatures \(1=\beta_0>\cdots>\beta_{R-1}>0\)

\[\begin{align*} \varrho_{\beta_r}(\vx)&\propto\widetilde\varrho_{\mathrm{tar}}(\vx)^{\beta_r} \end{align*}\]

  • Cold (\(\beta_0=1\)): original target; hot (\(\beta_r<1\)): flatter density, easier valley crossing
  • Each sweep: local Metropolis updates, then proposed state swaps between neighboring temperatures
  • Accept a swap \(\vx_r\leftrightarrow \vx_s\) with probability

\[\begin{align*} \alpha_{\mathrm{swap}} &=\min\left\{1, \left[\frac{\widetilde\varrho_{\mathrm{tar}}(\vx_s)}{\widetilde\varrho_{\mathrm{tar}}(\vx_r)}\right]^{\beta_r-\beta_s}\right\} \end{align*}\]

  • Accepted swaps bring hot-chain discoveries into the cold slot
  • Use cold-slot samples only for the original target; inspect mode visits and swap rates

Why this swap rule?

Temperatures stay in their slots; the two states trade places

Slot \(r\), density \(\varrho_{\beta_r}\) Slot \(s\), density \(\varrho_{\beta_s}\)
Before \(\vx_r\) \(\vx_s\)
After \(\vx_s\) \(\vx_r\)

Compare the product density after with the product density before:

\[\begin{align*} R_{\mathrm{swap}} &=\frac{\text{density after}}{\text{density before}} =\frac{\varrho_{\beta_r}(\vx_s)\,\varrho_{\beta_s}(\vx_r)} {\varrho_{\beta_r}(\vx_r)\,\varrho_{\beta_s}(\vx_s)} =\left[\frac{\widetilde\varrho_{\mathrm{tar}}(\vx_s)}{\widetilde\varrho_{\mathrm{tar}}(\vx_r)}\right]^{\beta_r-\beta_s} \end{align*}\]

  • Draw \(V\sim\Unif(0,1)\); swap if \(V\le\min\{1,R_{\mathrm{swap}}\}\)
  • Renaming \(r\) and \(s\): reciprocal density ratio and opposite exponent → same rule

Cold \(\beta_r=1\), hot \(\beta_s=1/2\), and \(\widetilde\varrho_{\mathrm{tar}}(\vx_s)=4\widetilde\varrho_{\mathrm{tar}}(\vx_r)\): \(R_{\mathrm{swap}}=\sqrt{4}=2\) → always swap; the reverse move is accepted with probability \(1/2\)

Kernel Discrepancy

Monte Carlo foundations, methods, and applications
Discrepancy
Measures

Kernels and discrepancy

Monte Carlo foundations, methods, and applications
Discrepancy
Measures
Analysis

Do our samples represent the target distribution?

  • Compare distributions using a kernel \(K(\vt,\vx)\)
  • A kernel specifies which spatial differences receive weight
  • Define the distribution discrepancy first, then substitute empirical distributions
  • Maximum mean discrepancy (MMD): the same kernel comparison used in machine learning

Discrepancy companion notebook

Tutorial: Hickernell, Kirk, Sorokin (2026), Section 5 — kernel discrepancy and integration error

The kernel determines which differences between distributions matter most

Symmetric positive definite kernels

A kernel \(K:\mathcal X\times\mathcal X\to\reals\) is symmetric positive definite when every Gram matrix

\[ \mK=(K(\vx_i,\vx_j))_{i,j=0}^{n-1} \]

is symmetric positive definite for distinct \(\vx_0,\ldots,\vx_{n-1}\)

Examples include

\[\begin{align*} K(\vt,\vx)&=\exp\!\left(-\norm{\vt-\vx}^2/h^2\right), &&\mathcal X=\reals^d,\\ K(\vt,\vx)&=\prod_{\ell=1}^d\left[1+\frac{\gamma_\ell^2}{2} \left(\abs{t_\ell-\tfrac12}+\abs{x_\ell-\tfrac12}-\abs{t_\ell-x_\ell}\right)\right], &&\mathcal X=[0,1]^d \end{align*}\]

  • First is a squared exponential kernel; second yields centered discrepancy

  • Kernels usually have parameters to be chosen or estimated

Discrepancy between distributions

Monte Carlo foundations, methods, and applications
Discrepancy
Measures

Compare any two distributions \(F,G\) on \(\mathcal X\)
Let \(\vR,\vR'\sim F\) and \(\vH,\vH'\sim G\) be mutually independent

\[\begin{align*} D^2(F,G;K) &=\Ex[K(\vR,\vR')]-2\Ex[K(\vR,\vH)]+\Ex[K(\vH,\vH')]\\ &=\int_{\mathcal X^2}K(\vx,\vx')\,\dif(F-G)(\vx)\,\dif(F-G)(\vx')\ge0 \end{align*}\]

If \(F,G\) have densities \(\varrho_F,\varrho_G\),

\[ D^2(F,G;K)=\int_{\mathcal X^2}K(\vx,\vx') \{\varrho_F(\vx)-\varrho_G(\vx)\} \{\varrho_F(\vx')-\varrho_G(\vx')\}\,\dif\vx\,\dif\vx' \]

For sample assessment, compare the target \(F_{\mathrm{tar}}\) with an empirical distribution

Empirical distributions

For candidate points in the target space, put mass \(1/n\) at each \(\vx_i\): \(\widehat F_n=n^{-1}\sum_{i=0}^{n-1}\delta_{\vx_i}\)

Compare \(F_{\mathrm{tar}}\) with \(\widehat F_n\) in the distribution formula:

\[\begin{align*} D^2(F_{\mathrm{tar}},\{\vx_i\}_{i=0}^{n-1};K) &=\int_{\mathcal X^2}K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx)\,\dif F_{\mathrm{tar}}(\vx')\\ &\quad-\frac{2}{n}\sum_{i=0}^{n-1}\int_{\mathcal X}K(\vx,\vx_i)\,\dif F_{\mathrm{tar}}(\vx)\\ &\quad+\frac{1}{n^2}\sum_{i,j=0}^{n-1}K(\vx_i,\vx_j) \end{align*}\]

Integration against an empirical distribution becomes averaging over its sample

Two empirical distributions

Use points \(\vx_i^{(F)}\) and \(\vx_j^{(G)}\); replace integrals by sums

\[\begin{align*} D^2\!\left(\{\vx_i^{(F)}\}_{i=0}^{m-1},\{\vx_j^{(G)}\}_{j=0}^{n-1};K\right) &=\frac{1}{m^2}\sum_{i,j=0}^{m-1}K(\vx_i^{(F)},\vx_j^{(F)})\\ &\quad-\frac{2}{mn}\sum_{i=0}^{m-1}\sum_{j=0}^{n-1}K(\vx_i^{(F)},\vx_j^{(G)}) +\frac{1}{n^2}\sum_{i,j=0}^{n-1}K(\vx_i^{(G)},\vx_j^{(G)}) \end{align*}\]

  • The exact squared discrepancy of these empirical distributions; nonnegative
  • Direct computation requires \(\Order(\max(m,n)^2)\) kernel evaluations
  • The answer depends on the chosen kernel and its parameters

Interpreting sample discrepancy

Monte Carlo foundations, methods, and applications
Discrepancy
Measures
Statistics

Two questions, two quantities

 

Question Quantity
How different are these empirical distributions? Exact \(D^2(\widehat F_m^{(F)},\widehat F_n^{(G)};K)\ge0\)
How different are the underlying distributions? Estimate \(D^2(F,G;K)\) from random samples
  • The ordinary empirical formula answers the first question
  • As an estimator of population discrepancy, it is generally biased
  • With independent IID samples, removing diagonal terms gives an unbiased estimator
  • Unbiased estimates may be negative; the population squared discrepancy is not

Unbiased estimates of squared discrepancy

For two independent IID samples, estimate \(D^2(F,G;K)\)

Replace within-sample sums by off-diagonal averages:

\[\begin{align*} D_{\mathrm{unb}}^2\!\left(\{\vx_i^{(F)}\}_{i=0}^{m-1},\{\vx_j^{(G)}\}_{j=0}^{n-1};K\right) &=\frac{1}{m(m-1)}\sum_{\substack{i,j=0\\i\ne j}}^{m-1}K(\vx_i^{(F)},\vx_j^{(F)})\\ &\quad-\frac{2}{mn}\sum_{i=0}^{m-1}\sum_{j=0}^{n-1}K(\vx_i^{(F)},\vx_j^{(G)}) +\frac{1}{n(n-1)}\sum_{\substack{i,j=0\\i\ne j}}^{n-1}K(\vx_i^{(G)},\vx_j^{(G)}) \end{align*}\]

Unbiased describes the estimator’s expectation, not the sign of each realization

A more negative realization is not a better match; it is a larger downward sampling fluctuation

What does unbiased mean?

\(\exstar\) Let \(\{\vR_i\}_{i=0}^{m-1}\) and \(\{\vH_j\}_{j=0}^{n-1}\) be independent IID samples from \(F\) and \(G\) Take expectations term by term to show \(\Ex[D_{\mathrm{unb}}^2]=D^2(F,G;K)\) What is the expectation when \(F=G\)? Why may a realization be negative, and does more negative mean a better match? Which step fails when the \(\vR_i\) are successive Metropolis states?

How small should discrepancy be?

Zero is the ideal; no universal acceptable cutoff

For a fixed target \(F_{\mathrm{tar}}\) and kernel \(K\), normalize by the no-sample error:

\[\begin{align*} D_0^2&=\int_{\mathcal X^2}K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx)\,\dif F_{\mathrm{tar}}(\vx')>0, &\qquad D_{\mathrm{rel},n}^2&=\frac{D^2(F_{\mathrm{tar}},\{\vx_i\}_{i=0}^{n-1};K)}{D_0^2} \end{align*}\]

  • \(D_{\mathrm{rel},n}^2<1\): improvement over estimating the integral by zero
  • Removes overall kernel amplitude; length scale and kernel shape still matter
  • No guaranteed \([0,1]\) range; compare samples using the same target and kernel
  • Study decay with \(n\): IID has \(\Ex[D_n^2]=C_K/n\), hence root mean squared discrepancy \(\Order(n^{-1/2})\)

Look for decreasing discrepancy and its asymptotic rate, together with the integration accuracy needed

Discrepancy as Integration Error

Monte Carlo foundations, methods, and applications
Error
Assessment

A reproducing kernel Hilbert space

Monte Carlo foundations, methods, and applications
Discrepancy
Measures
Analysis

Every symmetric positive definite kernel \(K\) defines a Hilbert space \(\mathcal H_K\) of functions on \(\mathcal X\) with the reproducing property

\[ f(\vx)=\langle K(\cdot,\vx),f\rangle_{\mathcal H_K} \]

Assume \(K\) is measurable and

\[ \int_{\mathcal X}\sqrt{K(\vx,\vx)}\,\dif F_{\mathrm{tar}}(\vx)<\infty \]

Then both

\[\begin{align*} f&\longmapsto\int_{\mathcal X}f(\vx)\,\dif F_{\mathrm{tar}}(\vx),\\ f&\longmapsto\int_{\mathcal X}f(\vx)\,\dif F_{\mathrm{tar}}(\vx)-\frac1n\sum_{i=0}^{n-1}f(\vx_i) \end{align*}\]

are bounded linear functionals on \(\mathcal H_K\)

Worst-case integration error

Monte Carlo foundations, methods, and applications
Error
Assessment

By the Riesz representation theorem, some \(\zeta\in\mathcal H_K\) satisfies

\[ \int_{\mathcal X}f(\vx)\,\dif F_{\mathrm{tar}}(\vx)-\frac1n\sum_{i=0}^{n-1}f(\vx_i) =\langle\zeta,f\rangle_{\mathcal H_K} \]

Therefore, by Cauchy–Schwarz,

\[ \left\lvert\int_{\mathcal X}f(\vx)\,\dif F_{\mathrm{tar}}(\vx)-\frac1n\sum_{i=0}^{n-1}f(\vx_i)\right\rvert \le\norm{\zeta}_{\mathcal H_K}\norm{f}_{\mathcal H_K} \]

This separates sample quality, \(\norm{\zeta}_{\mathcal H_K}\), from integrand difficulty, \(\norm{f}_{\mathcal H_K}\)

For \(\zeta\ne0\), the unit-norm integrand \(f=\zeta/\norm{\zeta}_{\mathcal H_K}\) attains the bound

The discrepancy identity

Monte Carlo foundations, methods, and applications
Error
Assessment

Fix \(\vx'\in\mathcal X\) and regard \(K(\cdot,\vx')\) as an integrand

Apply the reproducing property to \(\zeta\), then the error representation with \(f=K(\cdot,\vx')\):

\[\begin{align*} \zeta(\vx') &=\langle\zeta,K(\cdot,\vx')\rangle_{\mathcal H_K}\\ &=\int_{\mathcal X}K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx) -\frac1n\sum_{i=0}^{n-1}K(\vx_i,\vx') \end{align*}\]

Thus \(\zeta(\vx')\) is the true integral minus sample average for the kernel section \(K(\cdot,\vx')\)

The error representer is a function: at each \(\vx'\), its value is the integration error of the reproducing kernel anchored at \(\vx'\)

From the representer to squared discrepancy

Now use \(f=\zeta\) in the same error representation:

\[ \norm{\zeta}_{\mathcal H_K}^2 =\langle\zeta,\zeta\rangle_{\mathcal H_K} =\int_{\mathcal X}\zeta(\vx')\,\dif F_{\mathrm{tar}}(\vx') -\frac1n\sum_{j=0}^{n-1}\zeta(\vx_j) \]

Substitute the kernel-section error formula for each value of \(\zeta\); symmetry of \(K\) combines the two cross terms:

\[\begin{align*} \norm{\zeta}_{\mathcal H_K}^2 &=\int_{\mathcal X^2}K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx)\,\dif F_{\mathrm{tar}}(\vx')\\ &\quad-\frac2n\sum_{i=0}^{n-1}\int_{\mathcal X}K(\vx,\vx_i)\,\dif F_{\mathrm{tar}}(\vx) +\frac1{n^2}\sum_{i,j=0}^{n-1}K(\vx_i,\vx_j)\\ &=D^2(F_{\mathrm{tar}},\{\vx_i\}_{i=0}^{n-1};K) \end{align*}\]

Thus discrepancy is the worst-case error over \(\norm{f}_{\mathcal H_K}\le1\)

Average-case integration error

Monte Carlo foundations, methods, and applications
Error
Assessment

Suppose \(f\) is modeled as a zero-mean Gaussian process with covariance kernel \(K\)

For deterministic \(\vx_0,\ldots,\vx_{n-1}\),

\[\begin{align*} &\Ex_f\!\left[ \left\{\int_{\mathcal X}f(\vx)\,\dif F_{\mathrm{tar}}(\vx)-\frac1n\sum_{i=0}^{n-1}f(\vx_i)\right\}^2 \right]\\ &\quad=\int_{\mathcal X^2}K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx)\,\dif F_{\mathrm{tar}}(\vx') -\frac2n\sum_{i=0}^{n-1}\int_{\mathcal X}K(\vx,\vx_i)\,\dif F_{\mathrm{tar}}(\vx) +\frac1{n^2}\sum_{i,j=0}^{n-1}K(\vx_i,\vx_j)\\ &\quad=D^2(F_{\mathrm{tar}},\{\vx_i\}_{i=0}^{n-1};K) \end{align*}\]

Discrepancy is also the root mean squared error under the Gaussian-process model

Gaussianity is not required: the same RMSE identity holds for any zero-mean stochastic process with covariance kernel \(K\), provided the required second moments and integrals exist

What the kernel controls

Monte Carlo foundations, methods, and applications
Discrepancy
Measures
Statistics
  • The numerical value of discrepancy depends on \(K\) and its hyperparameters
  • Multiplying \(K\) by \(c^2\) multiplies discrepancy by \(\abs{c}\)
  • Kernel structure encodes assumptions about
    • domain and smoothness
    • periodicity
    • coordinate importance
  • In the average-case setting, hyperparameters may be estimated by empirical Bayes or maximum likelihood

For IID \(\vX_i\sim F_{\mathrm{tar}}\),

\[ \Ex\!\left[D^2(F_{\mathrm{tar}},\{\vX_i\}_{i=0}^{n-1};K)\right] =\frac1n\left\{ \int K(\vx,\vx)\,\dif F_{\mathrm{tar}}(\vx)-\int K(\vx,\vx')\,\dif F_{\mathrm{tar}}(\vx)\,\dif F_{\mathrm{tar}}(\vx') \right\} \]

Centered discrepancy and smoothness

Monte Carlo foundations, methods, and applications
Low
Discrepancy
Discrepancy
Measures

For \(\mathcal X=[0,1]^d\), the centered-discrepancy kernel is

\[ K(\vt,\vx)=\prod_{\ell=1}^d\left[1+\frac{\gamma_\ell^2}{2} \left(\abs{t_\ell-\tfrac12}+\abs{x_\ell-\tfrac12}-\abs{t_\ell-x_\ell}\right)\right] \]

Its norm combines the function value at the center with weighted square-integrals of mixed derivatives:

\[\begin{align*} \norm{f}_{\mathcal H_K}^2 &=\abs{f(1/2,\ldots,1/2)}^2 +\norm{\frac{\partial f(x_1,1/2,\ldots)}{\gamma_1\partial x_1}}_2^2\\ &\quad+\norm{\frac{\partial^2 f(x_1,x_2,1/2,\ldots)} {\gamma_1\gamma_2\partial x_1\partial x_2}}_2^2 +\cdots +\norm{\frac{\partial^d f(\vx)} {\gamma_1\cdots\gamma_d\partial x_1\cdots\partial x_d}}_2^2 \end{align*}\]

The weights \(\gamma_\ell\) express coordinate importance

Alternative comparisons

Monte Carlo foundations, methods, and applications
Discrepancy
Measures
Statistics

Relative entropy

Kullback–Leibler (KL) divergence, also called relative entropy

For normalized target density \(\varrho_{\mathrm{tar}}\) and comparison density \(\varrho_G\),

\[\begin{align*} D_{\mathrm{KL}}(F_{\mathrm{tar}}\Vert G) &=\int_{\mathcal X}\varrho_{\mathrm{tar}}(\vx) \log\!\left(\frac{\varrho_{\mathrm{tar}}(\vx)}{\varrho_G(\vx)}\right)\,\dif \vx \end{align*}\]

  • Nonnegative; zero exactly when the distributions agree
  • Generally asymmetric; infinite if \(F_{\mathrm{tar}}\) assigns mass where \(G\) assigns none
  • Entropy describes one distribution; relative entropy compares two
  • Variational inference fits an approximate density by minimizing KL to the target

Finite empirical sample versus continuous target: KL is infinite

Kernel discrepancy compares these directly, without density estimation

KL minimization with an unnormalized target

With \(\varrho_{\mathrm{tar}}=\widetilde\varrho_{\mathrm{tar}}/C\) and \(\vR\sim\varrho_{\mathrm{approx}}\),

\[\begin{align*} D_{\mathrm{KL}}(F_{\mathrm{approx}}\Vert F_{\mathrm{tar}}) &=\Ex_{\mathrm{approx}}\!\left[\log\!\left( \frac{\varrho_{\mathrm{approx}}(\vR)}{\widetilde\varrho_{\mathrm{tar}}(\vR)}\right)\right]+\log C \end{align*}\]

Fixed target: \(\log C\) does not affect minimization over the approximation

Stein discrepancy

For a smooth positive target density \(\varrho_{\mathrm{tar}}(\vx)=\widetilde\varrho_{\mathrm{tar}}(\vx)/C\), the score removes the unknown normalizing constant

\[\begin{align*} \boldsymbol s(\vx)&=\nabla_{\vx}\log\varrho_{\mathrm{tar}}(\vx) =\nabla_{\vx}\log\widetilde\varrho_{\mathrm{tar}}(\vx)\\ \mathcal T \boldsymbol g(\vx)&=\boldsymbol s(\vx)^\mathsf{T}\boldsymbol g(\vx)+\nabla\!\cdot \boldsymbol g(\vx), \qquad \boldsymbol g:\mathcal X\to\mathbb R^d \end{align*}\]

Stein’s identity: \(\Ex_{\mathrm{tar}}[\mathcal T \boldsymbol g(\vX)]=0\) for suitable \(\boldsymbol g\)

For candidate points \(\vx_0,\ldots,\vx_{n-1}\), write the error as true value minus sample average:

\[\begin{align*} D_{\mathrm{Stein}}(F_{\mathrm{tar}},\{\vx_i\};\mathcal G) &=\sup_{\boldsymbol g\in\mathcal G}\left| \underbrace{\Ex_{\mathrm{tar}}[\mathcal T \boldsymbol g(\vX)]}_{0} -\frac1n\sum_{i=0}^{n-1}\mathcal T \boldsymbol g(\vx_i)\right| \end{align*}\]

The largest departure from zero over a size-constrained class \(\mathcal G\) of test functions

Computing kernel Stein discrepancy

For kernel Stein discrepancy (KSD), choose \(\mathcal G\) as the unit ball of \(\mathcal H_K^d\)

The supremum has an explicit formula using a Stein kernel:

\[\begin{align*} K_{\mathrm{Stein}}(\vx,\vx') &=\boldsymbol s(\vx)^\mathsf{T}\boldsymbol s(\vx')K(\vx,\vx') +\boldsymbol s(\vx)^\mathsf{T}\nabla_{\vx'} K(\vx,\vx')\\ &\quad+\boldsymbol s(\vx')^\mathsf{T}\nabla_{\vx} K(\vx,\vx') +\sum_{\ell=1}^d\frac{\partial^2 K(\vx,\vx')}{\partial x_\ell\,\partial x'_\ell}\\[0.5ex] \mathrm{KSD}^2(F_{\mathrm{tar}},\{\vx_i\};K) &=\frac{1}{n^2}\sum_{i,j=0}^{n-1}K_{\mathrm{Stein}}(\vx_i,\vx_j)\ge0 \end{align*}\]

  • The target-integral terms vanish: only the sample-pair sum remains
  • Needs target scores and kernel derivatives; no target draws or normalizing constant

Requires smoothness and valid boundary conditions; kernel choice matters

Some KSDs fail to detect nonconvergence; separated-mode weights can be hard to assess

Comparing distribution discrepancies

Ordinary MMD KL / relative entropy Score-based KSD
Normalizing constant Direct integrals: needed; reference samples: not needed Value: generally needed; optimization: may drop out Cancels from the score
Benefit Sample comparisons; integration-error meaning Information-theoretic meaning; variational fitting No target draws or normalizer
Limitation Kernel choice; target integration or reference error Asymmetry; empirical vs continuous: infinite Derivatives; boundary, kernel, and mode sensitivity

Applications of Markov Chains

Monte Carlo foundations, methods, and applications
Practice
Markov Chain
Monte Carlo

Direct sampling, MCMC, and event simulation

Application What matters Natural simulation approach
Finance: European / Asian options Finite maturity; terminal value or path average Direct sampling of model inputs → independent paths; refine time steps as needed
Bayesian inference Complicated, concentrated posterior; often known only up to normalization MCMC when direct posterior sampling is difficult; mixing still matters
Queueing: waiting / blocking Arrival and departure order; interactions at individual events Event-driven simulation of the system’s Markov state; no fixed fine time grid
  • Finance: couple coarse and fine paths with multilevel Monte Carlo later
  • Barrier options: fine path detail can matter in finance too

Choose by access to the distribution and which details affect the answer

Maximum likelihood estimation

Monte Carlo foundations, methods, and applications
Statistical
Inference
Estimation

Our Monte Carlo error assessments so far have used a frequentist perspective

  • Frequentist: assess estimators by repeated-sampling bias, variance, and coverage; no likelihood is required
  • Fisherian / likelihood: compare parameter values through how well they explain the observed data
  • Bayesian: combine a sampling model with a prior to describe posterior uncertainty

These perspectives overlap: MLE can be assessed frequentist-wise, and Bayesian inference also uses likelihood

B. Efron & T. Hastie, Computer Age Statistical Inference (2016), Chapters 2–4

Likelihood and maximum likelihood estimation

The likelihood is the shared starting point for MLE and Bayesian inference

Let \(D\) denote data generated by the observation model
For observed data \(y_{\mathrm{obs}}\) and parameter \(\theta\),

\[ L(\theta;y_{\mathrm{obs}})=\varrho_{D\mid\theta}(y_{\mathrm{obs}}\mid\theta) \]

  • Use the sampling model’s density or probability mass function; no normality assumption
  • Hold \(y_{\mathrm{obs}}\) fixed and compare candidate parameter values \(\theta\)

The maximum likelihood estimator selects a maximizer:

\[ \htheta_{\mathrm{MLE}}\in\operatorname*{arg\,max}_{\theta}L(\theta;y_{\mathrm{obs}}) \]

MLE: maximize the likelihood for a point estimate
Bayesian inference: combine the same likelihood with a prior for a posterior distribution

Bayesian inference

Monte Carlo foundations, methods, and applications
Bayesian
Computation
Markov Chain
Monte Carlo
Statistics
  • Especially useful when data are limited relative to model complexity
  • Prior knowledge supplements the data; weak data call for checking sensitivity to the prior
  • Also useful with abundant data

Keep the sampling likelihood; now add prior information about \(\theta\):

\[\begin{align*} \varrho_{\mathrm{post}}(\theta\mid y_{\mathrm{obs}}) &=\frac{L(\theta;y_{\mathrm{obs}})\varrho_{\mathrm{prior}}(\theta)}{\varrho_D(y_{\mathrm{obs}})}\\ &\propto L(\theta;y_{\mathrm{obs}})\varrho_{\mathrm{prior}}(\theta) \end{align*}\]

Computing posterior summaries

  • The evidence \(\varrho_D(y_{\mathrm{obs}})\) depends only on the observed data
  • MCMC needs only the unnormalized posterior
  • Target samples \(X_i=\Theta_i\) represent \(\varrho_{\mathrm{post}}(\cdot\mid y_{\mathrm{obs}})\)
  • For a summary \(Y_i=f(X_i)\), estimate \(\mu=\Ex_{\mathrm{post}}[f(X)]\) by averaging
  • Posterior quantiles and credible intervals use the sampled distribution
  • Optimization of the unnormalized posterior yields a maximum a posteriori estimate

Bayesian inference is a primary reason to sample from complicated unnormalized densities

BayesianMCMC companion notebook

Queueing systems

Monte Carlo foundations, methods, and applications
Practice
Probability

First distinguish full input durations from event-state clocks.

Full durations are quantile transforms of uniform inputs; assume they are mutually independent:

\[ D_{k}^{\mathrm{arr}}\sim F_A \quad\text{($k$th interarrival duration)}, \qquad D_{j}^{\mathrm{srv}}\sim F_S \quad\text{(customer $j$'s full service time)}. \]

Immediately after event \(i\), the state is \(\vQ_i=(A_i,N_i,S_i), \qquad i=0,1,\ldots\), where

\[\begin{align*} A_i&=\text{time until the next arrival},\\ N_i&=\text{number of customers in the system},\\ S_i&=\text{remaining service time}, \qquad S_i=\infty\text{ when the server is idle} \end{align*}\]

  • At the \(k\)th arrival, load the next arrival clock with \(D_{k+1}^{\mathrm{arr}}\)

  • When customer \(j\) begins service, load the service clock with \(D_{j}^{\mathrm{srv}}\)

  • For performance, also track \(\tau_j=\) accumulated time in the system for customer \(j\)

The state \(\vQ_i\) determines the next-event law. The \(\tau_j\) clocks measure customer time but do not affect that law

The next queue event

  • The next event occurs after \(\Delta t_i=\min(A_i,S_i)\)

    • Arrival: \(A_i<S_i\)
    • Service completion: \(S_i\leq A_i\)
  • During the interval from event \(i\) to event \(i+1\)

    • Simulated time: \(t_{i+1}=t_i+\Delta t_i\)
    • Both active state clocks count down by \(\Delta t_i\)
    • Each customer present gains \(\tau_j\leftarrow \tau_j+\Delta t_i\)
  • At the event

    • Update \(N_{i+1}\)
    • On arrival, set the new customer’s \(\tau_j=0\)
    • On service completion, record the departing customer’s \(\tau_j\)
    • Load each clock that starts anew with its next full input duration
    • Carry every other active clock’s residual time forward

Markov interpretation

If we jump into the process at \(i=47\), knowing \(\vQ_{47}=(A_{47},N_{47},S_{47})\) and using future independent input durations lets us continue with \(\vQ_{48},\vQ_{49},\ldots\) without knowing the earlier queue states \(\vQ_0,\ldots,\vQ_{46}\)

  • The residual clocks belong in the state because a partially elapsed duration generally does not have the same distribution as a newly drawn full duration

Example. If \(D_{j}^{\mathrm{srv}}\sim\Unif(4,8)\) and five minutes of customer \(j\)’s service have elapsed, the remaining time has distribution

\[ D_{j}^{\mathrm{srv}}-5\mid D_{j}^{\mathrm{srv}}>5\sim\Unif(0,3), \qquad \text{not }\Unif(4,8) \]

  • In the taxi example, the interarrival durations \(D_{k}^{\mathrm{arr}}\) were exponential and therefore memoryless:

\[ D_{k}^{\mathrm{arr}}-t\mid D_{k}^{\mathrm{arr}}>t\sim\Exp(\lambda) \]

Event-driven queue simulation

Initialize i = 0, t[0] = 0, A[0] = arrival_duration[1], N[0] = 0, S[0] = infinity
while i < i_max and t[i] < t_max:  # event or simulated-time limit
    delta_t_i = min(A[i], S[i])  # S[i] = infinity while idle
    if t[i] + delta_t_i >= t_max: stop at t_max without processing the event
    t[i+1] = t[i] + delta_t_i
    if A[i] < S[i]:  # arrival
        N[i+1] = N[i] + 1
        A[i+1] = next unused arrival_duration[k]
        if N[i] == 0:
            S[i+1] = service_duration[j] for the arriving customer j
        else: S[i+1] = S[i] - delta_t_i
    else:  # service completion
        N[i+1] = N[i] - 1
        A[i+1] = A[i] - delta_t_i
        if N[i+1] > 0:
            S[i+1] = service_duration[j] for the next customer j
        else: S[i+1] = infinity
    i = i + 1

Events replace fixed time steps, avoiding work when nothing changes

Queue simulation companion notebook

Queue simulation example

The full interarrival and service draws are given. Use each row from left to right:

Draw First Second Third
Interarrival \(D_{k}^{\mathrm{arr}}\) \(2\) \(1.5\) \(5\)
Service \(D_{j}^{\mathrm{srv}}\) \(5\) \(1\) \(4\)

Example. Start empty at \(t_0=0\); \(\Delta t_i\) is the time to the next event.

\(i\) Event \(i\) \(t_i\) \(A_i\) \(N_i\) \(S_i\) \(\Delta t_i\)
0 start 0 2 0 \(\infty\) 2
1 arrival 1 2 1.5 1 5 1.5
2 arrival 2 3.5 5 2 3.5 3.5
3 service completion 1 7 1.5 1 1 1
4 service completion 2 8 0.5 0 \(\infty\) –

Draw a new service time only when a customer begins service

After event \(\tau_1\) \(\tau_2\)
0 – –
1 0 –
2 1.5 0
3 5, done 3.5
4 5, done 4.5, done

\(\exstar\) Queue simulation exercise

For each table, start empty at \(t_0=0\). Process events until the supplied draws no longer determine which event comes next; do not invent another draw.

Draw First Second Third
Interarrival \(D_{k}^{\mathrm{arr}}\) \(3\) \(5\) \(4\)
Service \(D_{j}^{\mathrm{srv}}\) \(1\) \(2\) \(6\)
Draw First Second Third
Interarrival \(D_{k}^{\mathrm{arr}}\) \(1\) \(2\) \(6\)
Service \(D_{j}^{\mathrm{srv}}\) \(5\) \(2\) \(4\)
Draw First Second Third
Interarrival \(D_{k}^{\mathrm{arr}}\) \(2\) \(1\) \(1\)
Service \(D_{j}^{\mathrm{srv}}\) \(5\) \(2\) \(6\)

Report the event sequence and customer times. Which service draws remain unused, and why?

Big Ideas

Monte Carlo foundations, methods, and applications
Practice
Markov Chain
Monte Carlo
Discrepancy
Measures
  • A Markov chain’s next-state law depends on its current state
  • Metropolis–Hastings corrects a proposal mechanism so that the target distribution is invariant
  • Bayesian inference: MCMC samples complicated posteriors known only up to normalization
  • Kernel discrepancy compares distributions and measures both worst-case and average-case integration error
  • The kernel specifies which distributional differences and integrand features matter
  • Queueing: simulate arrivals and service completions from the current state; measure customer time and blocking

How Far We Have Come

From random inputs to distribution-aware simulation

  • Estimate — expectations, quantiles, and uncertainty
    Travel time: how long should we allow?
  • Generate — transform uniform inputs into vectors and paths
    Option pricing: average discounted payoffs
  • Extend — MCMC samples targets known only up to normalization
    Bayesian inference: compute posterior summaries
  • Simulate — advance a Markov system from its current state
    Queueing: customer time and blocking
  • Assess — kernel discrepancy connects distributional fit with integration error

Sampling tells us what to compute; discrepancy helps judge how well the samples represent the target

What Comes Next

We now have ways to generate samples and assess their error

Improving Efficiency asks how to get a more accurate answer for the same computational work:

«
»