
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
October 9, 2026
\[\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 a global sampling construction to a target-preserving transition
Under suitable conditions, the distribution of \(X_i\) approaches the target as \(i\to\infty\)
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\)
Assume \(\epsilon_0,\epsilon_1,\ldots\ \IIDsim\ \Norm(0,1)\)
\[\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\)
\[ 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
For states in \(\reals^d\), suppose
Given \(\vX_0\), repeat for \(i=0,\ldots,n-2\):
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
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\} \]
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
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}} \]
Detailed balance preserves the target; convergence from the starting state requires suitable conditions
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\):
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
Target a bimodal Gaussian mixture using the symmetric proposal
\[ Z\mid X_i=x\sim\Norm(x,1.4^2) \]

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

Acceptance within a mode does not establish exploration of both modes
MCMC is attractive because it
The proposal and starting point require care:
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
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*}\]
\[\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*}\]
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*}\]
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\)
Do our samples represent the target distribution?
Discrepancy companion notebook
Tutorial: Hickernell, Kirk, Sorokin (2026), Section 5 — kernel discrepancy and integration error
The kernel determines which differences between distributions matter most
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
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
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
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*}\]
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 |
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
\(\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?
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*}\]
Look for decreasing discrepancy and its asymptotic rate, together with the integration accuracy needed
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\)
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
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'\)
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\)
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
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\} \]
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
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*}\]
Finite empirical sample versus continuous target: KL is infinite
Kernel discrepancy compares these directly, without density estimation
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
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
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*}\]
Requires smoothness and valid boundary conditions; kernel choice matters
Some KSDs fail to detect nonconvergence; separated-mode weights can be hard to assess
| 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 |
| 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 |
Choose by access to the distribution and which details affect the answer
Our Monte Carlo error assessments so far have used a frequentist perspective
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
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) \]
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
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*}\]
Bayesian inference is a primary reason to sample from complicated unnormalized densities
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 event occurs after \(\Delta t_i=\min(A_i,S_i)\)
During the interval from event \(i\) to event \(i+1\)
At the event
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}\)
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) \]
\[ D_{k}^{\mathrm{arr}}-t\mid D_{k}^{\mathrm{arr}}>t\sim\Exp(\lambda) \]
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 + 1Events replace fixed time steps, avoiding work when nothing changes
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 |
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?
From random inputs to distribution-aware simulation
Sampling tells us what to compute; discrepancy helps judge how well the samples represent the target
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:
© 2026 Fred J. Hickernell · Illinois Tech · assisted by ChatGPT and Codex · MCMC · MATH 565 — Fall 2026 Website · \(\exstar\) = exercise