MATH 565 — Fall 2026

Generating Samples
Owen, Chapters 3–6 and 15–17
Assignment 2 due Sep 11
Assignment 3 due Sep 25
Test 1 · Sep 15

Fred J. Hickernell

October 9, 2026

Course Map

Monte Carlo foundations, methods, and applications
Probability
Analysis
Linear
Algebra
(Quasi-)Random
Number Generation
Pseudorandom
Numbers
Low
Discrepancy
Quantitative
Finance

\[ \vU_i \sim \Unif[0,1]^d \;\longrightarrow\; \vX_i \sim \varrho_{\mathrm{tar}} \;\longrightarrow\; Y_i = f(\vX_i) \]

\[ \mu=\Ex(Y),\qquad \hmu_n=\frac1n\sum_{i=0}^{n-1}Y_i \]

From Uniformity to a Target Distribution

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Where do random variables come from?

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation
  • Algorithms generate sequences—typically in \([0,1]\)—designed to mimic IID uniform random variables
  • Pseudorandom number generators are tested so that their output looks IID random in many demanding ways
  • Parallel computation requires special care: streams must not overlap or acquire unintended dependence
  • RANDU is a classic warning: simple-looking output can conceal severe higher-dimensional structure
  • Physical generators may supply genuine randomness, but do not by themselves guarantee IID samples from the desired distribution

A stork carrying a bag labeled random variable, crossed out with a large red X

Uniform numbers are the raw material

A transformation produces the target distribution

The quantile transform

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

A sampling design supplies

\[ U_i\sim\Unif[0,1],\qquad i=0,1,\ldots \]

The design may be IID, Latin hypercube, low discrepancy, or something else

For a target cumulative distribution function \(F\), define

\[ Q(u):=\inf\{x\in\reals:F(x)\ge u\} \]

Then \(Q(u)\le x \iff u\le F(x)\)

 

For \(X:=Q(U)\)

\[ \Prob(X\le x)=\Prob\{Q(U)\le x\} =\Prob\{U\le F(x)\}=F(x) \]

Thus each \(X_i:=Q(U_i)\) has the target CDF \(F\)

IID inputs yield IID targets
Other designs (Latin hypercube, low discrepancy, …) retain their dependence structure

Try the quantile-transform examples in the companion GeneratingSamples notebook

Binomial random numbers

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Suppose \(X\sim\Bin(3,0.6)\)

\(x\) \(0\) \(1\) \(2\) \(3\)
PMF \(\varrho_X(x)\) \(0.4^3\)
\(=0.064\)
\(3(0.6)(0.4^2)\)
\(=0.288\)
\(3(0.6^2)(0.4)\)
\(=0.432\)
\(0.6^3\)
\(=0.216\)
\(x\in\) \([0,1)\) \([1,2)\) \([2,3)\) \([3,\infty)\)
CDF \(F(x)\) \(0.064\) \(0.352\) \(0.784\) \(1\)
\(u\in\) \((0,0.064]\) \((0.064,0.352]\) \((0.352,0.784]\) \((0.784,1]\)
Quantile \(Q(u)\) \(0\) \(1\) \(2\) \(3\)

E.g., \(U_0=0.63\), \(U_1=0.02\), and \(U_2=0.47\) produce \(X_0=2\), \(X_1=0\), and \(X_2=2\)

\(\exstar\) If \(u=0.70\), what value does the inverse transform produce? What about \(u=0.90\)?

CDF and quantile function for a binomial distribution with three trials and success probability 0.6, showing right-continuous CDF steps and left-continuous quantile steps

\(F\) is right-continuous; \(Q\) is left-continuous

Zero-inflated exponential random numbers

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

CDF

Let \(X\) be nonnegative with

  • Probability \(p_0\) of being zero and
  • Otherwise an exponential distribution with rate (mean\({}^{-1}\)) \(\lambda\)

\[ \Prob(X=0)=p_0, \qquad X\mid X>0\sim\Exp(\lambda) \]

Its CDF is

\[ F(x)= \begin{cases} 0, & x<0,\\ p_0, & x=0,\\ p_0+(1-p_0)(1-\me^{-\lambda x}), & x>0 \end{cases} \]

For the plot, \(p_0=0.3\) and \(\lambda=1\)

CDF of a zero-inflated exponential distribution, showing a jump of size p zero at x equals zero

Quantile

Inverting the CDF gives

\[ Q(u)= \begin{cases} 0, & 0<u\le p_0,\\[0.4em] -\dfrac{1}{\lambda}\log\!\left(\dfrac{1-u}{1-p_0}\right), & p_0<u<1 \end{cases} \]

\(\exstar\) Verify that \(F\bigl(Q(u)\bigr)\ge u\) and identify where equality fails

For the plot, \(p_0=0.3\) and \(\lambda=1\)

Quantile function of a zero-inflated exponential distribution, showing a flat segment from zero to p zero

An alternative transform

\(\exstar\) Define \(T(u):=Q(1-u)\).
Simplify \(T\) and explain why \(T(U)\) has the desired distribution for \(U\sim\Unif(0,1)\) even though \(T\) is not the quantile function.
Why might \(T\) be preferred to \(Q\)?

The generalized inverse handles atoms and continuous pieces with one definition

Gaussian mixture random numbers

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Let the one-dimensional target be a Gaussian mixture:

\[ X\sim p\Norm(\mu_1,\sigma_1^2)+(1-p)\Norm(\mu_2,\sigma_2^2), \qquad 0<p<1 \]

Writing \(\phi\) and \(\Phi\) for the standard normal PDF and CDF,

\[\begin{align*} \varrho_X(x) &=\frac{p}{\sigma_1}\phi\!\left(\frac{x-\mu_1}{\sigma_1}\right) +\frac{1-p}{\sigma_2}\phi\!\left(\frac{x-\mu_2}{\sigma_2}\right),\\ F_X(x) &=p\Phi\!\left(\frac{x-\mu_1}{\sigma_1}\right) +(1-p)\Phi\!\left(\frac{x-\mu_2}{\sigma_2}\right) \end{align*}\]

The PDF and CDF have analytic formulas, but the mixture quantile \(Q=F_X^{-1}\) generally has no analytic closed form

Sampling without the mixture quantile

Numerically inverting \(F_X\) would work, but a hierarchical construction avoids solving \(F_X(x)=u\)

Generate independent \(U_1,U_2\sim\Unif(0,1)\)
The last coordinate \(U_2\) selects the component; \(U_1\) supplies the normal quantile

\[ C=\begin{cases}1,&U_2\le p,\\2,&U_2>p,\end{cases} \qquad X=\mu_C+\sigma_C\Phi^{-1}(U_1) \]

Then \(\Prob(C=1)=p\) and \(X\mid C=k\sim\Norm(\mu_k,\sigma_k^2)\)

A mixture chains a discrete component choice with a within-component transform

A concrete mixture

Take

\[\begin{align*} p&=0.3,\\ (\mu_1,\sigma_1)&=(-2,0.5),\\ (\mu_2,\sigma_2)&=(1,1) \end{align*}\]

For \(U_1=0.90\) and \(U_2=0.24\),

\[\begin{align*} C&=1,\\ X&=-2+0.5\Phi^{-1}(0.90)\\ &\approx -1.36 \end{align*}\]

\(\exstar\) Use \(U_1=0.25\) and \(U_2=0.70\).
Which component is selected?
What value of \(X\) is generated?

Density of a two-component Gaussian mixture with both weighted component densities shown

Random Vectors and Stochastic Processes

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Independent marginals

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

For \(\vX=(X_1,\ldots,X_d)\) with independent marginals

\[ \vX=\bigl(Q_1(U_1),\ldots,Q_d(U_d)\bigr), \qquad \vU\sim\Unif[0,1]^d \]

where \(Q_j\) is the quantile function for the target distribution of \(X_j\)

Store \(n\) sampled vectors as an \(n\times d\) array:

\[ \mX= \begin{pmatrix} X_{01} & X_{02} & \cdots & X_{0d}\\ \vdots & \vdots & & \vdots\\ X_{n-1,1} & X_{n-1,2} & \cdots & X_{n-1,d} \end{pmatrix} \]

Rows are samples
Columns are coordinates

Multivariate normal sampling

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Set \(Z_j=\Phi^{-1}(U_j)\) for independent uniform inputs
Let \(\vZ\sim\Norm(\vzero,\mI_d)\) be a column vector of \(d\) independent standard normal random variables, so

\[ \Ex(\vZ)=\vzero, \qquad \Ex(\vZ\vZ^\mathsf{T})=\mI_d \]

The affine transport is \(\vT(\vz)=\mA\vz+\vmu\)
Define \(\vX=\vT(\vZ)\). Then

\[\begin{align*} \Ex(\vX) &= \vmu,\\ \cov(\vX) &= \Ex\bigl[(\vX-\vmu)(\vX-\vmu)^\mathsf{T}\bigr] =\Ex(\mA\vZ\vZ^\mathsf{T}\mA^\mathsf{T})\\ &=\mA\Ex(\vZ\vZ^\mathsf{T})\mA^\mathsf{T} =\mA\mA^\mathsf{T} \end{align*}\]

Every linear combination of the components of \(\vX\) is normal

Thus, if \(\mSigma=\mA\mA^\mathsf{T}\),

\[ \vX=\mA\vZ+\vmu\sim\Norm(\vmu,\mSigma) \]

Cholesky factorization

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Concrete example

For symmetric positive-definite \(\mSigma\), Cholesky factorization gives a lower-triangular \(\mA\) such that \(\mSigma=\mA\mA^\mathsf{T}\)

For

\[ \mSigma=\begin{pmatrix}3&-1\\-1&1\end{pmatrix}, \qquad \mA=\begin{pmatrix}a_{11}&0\\a_{21}&a_{22}\end{pmatrix} \]

matching the entries of \(\mSigma=\mA\mA^\mathsf{T}\) gives

\[\begin{align*} a_{11}^2&=3, &a_{11}a_{21}&=-1, &a_{21}^2+a_{22}^2&=1 \end{align*}\]

Hence

\[ a_{11}=\sqrt3, \qquad a_{21}=-\frac1{\sqrt3}, \qquad a_{22}=\sqrt{\frac23}, \qquad \mA_{\mathrm{Chol}} =\begin{pmatrix}\sqrt3&0\\-1/\sqrt3&\sqrt{2/3}\end{pmatrix} \]

General \(2\times2\) covariance

For

\[ \mSigma= \begin{pmatrix} \sigma_1^2 & \rho\sigma_1\sigma_2\\ \rho\sigma_1\sigma_2 & \sigma_2^2 \end{pmatrix}, \qquad \mA= \begin{pmatrix} \sigma_1 & 0\\ \rho\sigma_2 & \sigma_2\sqrt{1-\rho^2} \end{pmatrix} \]

Different factorizations generate the same distribution
They may behave differently under low discrepancy sampling

Principal-component (PCA) factorization

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

For the same covariance matrix as in the Cholesky example,

\[ \mSigma=\begin{pmatrix}3&-1\\-1&1\end{pmatrix}, \]

let \(c=\cos(\mpi/8)\) and \(s=\sin(\mpi/8)\)

The ordered eigendecomposition is

\[ \mV=(\vv_1\ \vv_2)= \begin{pmatrix}c&s\\-s&c\end{pmatrix}, \qquad \mLambda=\operatorname{diag}(2+\sqrt2,\,2-\sqrt2) \]

The PCA factor simplifies to

\[ \mA_{\mathrm{PCA}}=\mV\mLambda^{1/2} =\begin{pmatrix} 1+1/\sqrt2&1-1/\sqrt2\\ -1/\sqrt2&1/\sqrt2 \end{pmatrix} \]

Thus \(\mA_{\mathrm{PCA}}\mA_{\mathrm{PCA}}^\mathsf{T} =\mV\mLambda\mV^\mathsf{T}=\mSigma\), just as for the Cholesky factor

Gaussian processes

Monte Carlo foundations, methods, and applications
Probability

A Gaussian process is a random function whose values at any finite collection of inputs form a multivariate normal random vector

\[ G\sim\GP(m,K) \]

means

\[\begin{align*} \Ex[G(t)] &= m(t),\\ \Ex\bigl[\{G(t)-m(t)\}\{G(x)-m(x)\}\bigr] &= K(t,x) \end{align*}\]

For inputs \(t_1,\ldots,t_d\), let \(\mu_j=m(t_j)\)

\[ \bigl(G(t_1),\ldots,G(t_d)\bigr)^\mathsf{T} \sim\Norm(\vmu,\mSigma), \qquad \Sigma_{jk}=K(t_j,t_k) \]

Brownian motion

Monte Carlo foundations, methods, and applications
Probability

Definition

Brownian motion \(B\) is the Gaussian process with

\[ m(t)=0, \qquad K(t,x)=\min(t,x), \qquad t,x\ge0 \]

For \(0=t_0<t_1<\cdots<t_d\)

\[ \bigl(B(t_1),\ldots,B(t_d)\bigr)^\mathsf{T} \sim\Norm(\vzero,\mSigma), \qquad \Sigma_{jk}=\min(t_j,t_k) \]

The covariance structure implies independent normal increments

Covariance matrix and Cholesky factor

For \(0<t_1<t_2<t_3\), let \(\Delta t_1=t_1\) and \(\Delta t_j=t_j-t_{j-1}\). Then

\[ \mSigma= \begin{pmatrix} t_1&t_1&t_1\\ t_1&t_2&t_2\\ t_1&t_2&t_3 \end{pmatrix}, \qquad \mA= \begin{pmatrix} \sqrt{\Delta t_1}&0&0\\ \sqrt{\Delta t_1}&\sqrt{\Delta t_2}&0\\ \sqrt{\Delta t_1}&\sqrt{\Delta t_2}&\sqrt{\Delta t_3} \end{pmatrix}, \qquad \mSigma=\mA\mA^\mathsf{T} \]

Each entry sums the increments shared by both times:

\[ (\mA\mA^\mathsf{T})_{jk} =\sum_{\ell=1}^{\min(j,k)}\Delta t_\ell =t_{\min(j,k)} \]

In general, \(A_{jk}=\sqrt{\Delta t_k}\) for \(k\le j\) and \(A_{jk}=0\) otherwise

Sampling

Let \(Z_j=\Phi^{-1}(U_j)\), so \(Z_1,\ldots,Z_d\ \IIDsim\ \Norm(0,1)\)
Start from \(B(t_0)=0\)

\[ B(t_j)=B(t_{j-1})+\sqrt{t_j-t_{j-1}}\,Z_j, \qquad j=1,\ldots,d \]

Equivalently

\[ B(t_j)=\sum_{k=1}^j\sqrt{t_k-t_{k-1}}\,Z_k \]

The Cholesky construction is the familiar cumulative-sum construction for Brownian motion

Geometric Brownian motion

Monte Carlo foundations, methods, and applications
Probability

For \(S_0>0\), drift \(\gamma\), and volatility \(\sigma>0\), define

\[ S(t)=S_0\exp\!\left[ \left(\gamma-\frac{\sigma^2}{2}\right)t+\sigma B(t) \right] \]

Then \(S(t)>0\) and its multiplicative increments are lognormal

\(\exstar\) Using \(B(t)\sim\Norm(0,t)\) and the normal moment-generating function, show that \(\Ex[S(t)]=S_0\me^{\gamma t}\).
Hence determine \(\gamma\) so that \(\Ex[S(t)]=S_0\me^{rt}\).

The correction \(-\sigma^2/2\) makes \(\gamma\) the mean growth rate
The median growth rate is \(\gamma-\sigma^2/2\)

Why the mean exceeds the median

Let

\[ m(t)=S_0\me^{(\gamma-\sigma^2/2)t}, \]

the median of \(S(t)\)

\(\exstar\) The normal density weights the shocks \(b\) and \(-b\) equally. Show that \[ \frac{m(t)\me^{\sigma b}+m(t)\me^{-\sigma b}}{2} =m(t)\cosh(\sigma b)>m(t),\qquad b\ne0. \] Why do equal and opposite log shocks not cancel in price?

Risk-neutral asset-price paths

For a non-dividend-paying asset with continuously compounded risk-free rate \(r\), the risk-neutral model sets \(\gamma=r\)

On \(0=t_0<t_1<\cdots<t_d=T\), define \(\Delta t_j:=t_j-t_{j-1}\)

For \(Z_1,\ldots,Z_d\ \IIDsim\ \Norm(0,1)\),

\[ S_j=S_{j-1}\exp\!\left[ \left(r-\frac{\sigma^2}{2}\right)\Delta t_j +\sigma\sqrt{\Delta t_j}\,Z_j \right], \qquad j=1,\ldots,d \]

For equally spaced monitoring times, \(\Delta t_j=T/d\)

The simulated vector \((S_1,\ldots,S_d)\) is the discrete asset path used to evaluate option payoffs

Option payoffs and prices

Monte Carlo foundations, methods, and applications
Quantitative
Finance

Let \(\vX=(B(t_1),\ldots,B(t_d))\) be the target Brownian path
The function \(f\) builds the asset path and returns its discounted payoff

\[ Y=f(\vX)=\text{discounted payoff},\qquad \mu=\Ex(Y) \]

\[\begin{align*} K &= \text{the }\alert{\text{strike price}}, & T &= \text{the }\alert{\text{time to maturity}},\\ t_j &= jT/d, & S_j &= S(t_j), \qquad j=0,\ldots,d \end{align*}\]

Contract Discounted payoff
European call \(\me^{-rT}\max\{S_d-K,0\}\)
European put \(\me^{-rT}\max\{K-S_d,0\}\)
Arithmetic Asian call \(\displaystyle \me^{-rT}\max\left\{\frac1T\int_0^T S(t)\,\dif t-K,0\right\}\approx \me^{-rT}\max\{A_d-K,0\}\)

QMCPy FinancialOption offers the right and trapezoidal rules:

\[ \begin{aligned} A_d^{\mathrm{right}} &=\frac1d\sum_{j=1}^d S_j, & A_d^{\mathrm{trap}} &=\frac1d\left(\frac{S_0}{2}+\sum_{j=1}^{d-1}S_j+\frac{S_d}{2}\right) \end{aligned} \]

Path-dependent contracts

Asian, lookback, and barrier payoffs depend on the monitored path, not only the terminal price \(S_d\)

At the monitoring times define

\[ m_d:=\min_{0\le j\le d}S_j, \qquad M_d:=\max_{0\le j\le d}S_j \]

For a barrier \(B\), let \(\mathcal A_B\) be the event that the discretely monitored path activates the option

QMCPy takes \(S_0<B\) for an up barrier and \(S_0>B\) for a down barrier

\[ \begin{array}{ll} \text{up-in}: \mathcal A_B=\{M_d\ge B\}, & \text{up-out}: \mathcal A_B=\{M_d<B\},\\ \text{down-in}: \mathcal A_B=\{m_d\le B\}, & \text{down-out}: \mathcal A_B=\{m_d>B\} \end{array} \]

Lookback and barrier payoffs

Using \(m_d\), \(M_d\), and \(\mathcal A_B\) from the preceding slide:

Contract Discounted payoff
Lookback call \(\me^{-rT}(S_d-m_d)\)
Lookback put \(\me^{-rT}(M_d-S_d)\)
Barrier call \(\me^{-rT}\max\{S_d-K,0\}\indic(\mathcal A_B)\)
Barrier put \(\me^{-rT}\max\{K-S_d,0\}\indic(\mathcal A_B)\)

American put: optimal stopping

At the exercise times \(t_0,\ldots,t_d\), the holder chooses a stopping index \(J\) using only prices observed through \(t_J\)

Let \(\mathcal T_d\) be the set of these stopping indices. The fair price is

\[ \mu_{\mathrm{AmPut}} =\sup_{J\in\mathcal T_d} \Ex\!\left[ \me^{-rt_J}\max\{K-S_J,0\} \right] \]

  • A European put restricts exercise to \(J=d\)
  • An American put may exercise earlier when doing so is more valuable
  • With no dividends and \(r\ge0\), early exercise does not improve an American call, so we omit it here

Low Discrepancy Sampling

Monte Carlo foundations, methods, and applications
Low
Discrepancy

What does low discrepancy mean?

Monte Carlo foundations, methods, and applications
Low
Discrepancy

Relaxing the requirement that \(\vU_0,\ldots,\vU_{n-1}\) be IID allows carefully constructed samples to cover \([0,1]^d\) more evenly

\[ \vU_0,\ldots,\vU_{n-1}\ \LDsim\ \Unif[0,1]^d \]

The empirical distribution of the sample is close to the uniform distribution

Discrepancy quantifies that difference; precise definitions come later

Low discrepancy replaces independent placement by deliberate coverage

Low discrepancy sequences

Monte Carlo foundations, methods, and applications
Low
Discrepancy

Important families include

  • digital sequences, especially Sobol’ sequences
  • lattice sequences
  • Halton sequences
  • Kronecker sequences

They are available in deterministic and randomized forms through SciPy and QMCPy

In software arrays rows correspond to samples and columns to coordinates

Why coordinate order matters

Monte Carlo foundations, methods, and applications
Low
Discrepancy

Return to the PCA factorization:

\[ \vX-\vmu =\sqrt{2+\sqrt2}\,\vv_1\Phi^{-1}(U_1) +\sqrt{2-\sqrt2}\,\vv_2\Phi^{-1}(U_2) \]

so \(U_1\) drives \(\lambda_1/(\lambda_1+\lambda_2)=(2+\sqrt2)/4\approx85.4\%\) of the total marginal variance

  • IID inputs: column order does not change the distribution
  • Low discrepancy inputs: column order changes which coordinate drives each principal direction

Put the largest eigenvalues first so dominant directions use the low-numbered coordinates, where many low discrepancy constructions are strongest

More Advanced Direct Sampling

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Transport maps and acceptance–rejection notebook

Transport maps

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

The quantile transform is a one-dimensional transport

In \(d\) dimensions

  • Start with an easy proposal density \(\varrho_{\mathrm{prop}}\)
  • Seek the target density \(\varrho_{\mathrm{tar}}\) through an invertible, differentiable map \(\vT:\reals^d\to\reals^d\)
    Let \(\vZ\sim\varrho_{\mathrm{prop}}\) and \(\vX=\vT(\vZ)\)

The map transports the proposal to the target when \(\varrho_{\mathrm{tar}}\bigl(\vT(\vz)\bigr) \left|\det\nabla \vT(\vz)\right| =\varrho_{\mathrm{prop}}(\vz)\)

Then, for every integrable function \(f\),

\[\begin{align*} \Ex_{\mathrm{tar}}[f(\vX)] &=\Ex_{\mathrm{prop}}[f\bigl(\vT(\vZ)\bigr)]\\ &\approx \frac1n\sum_{i=0}^{n-1}f\bigl(\vT(\vZ_i)\bigr), \qquad \vZ_0,\ldots,\vZ_{n-1}\ \IIDsim\ \varrho_{\mathrm{prop}} \end{align*}\]

An exact transport moves every proposal sample and makes the correction weight equal to one

Normalizing flow builds a flexible transport by composing manageable invertible maps, \(\vT=\vT_m\circ\cdots\circ \vT_1\)

How is \(\vT\) chosen?

Mechanics

  • Choose a tractable family \(\vT_\theta\): affine, triangular, or a composition of simple invertible maps
  • Determine \(\theta\) analytically when possible
    Otherwise fit it so the density-matching equation holds approximately
  • Add an optimality criterion when needed
    Quadratic-cost transport leads to a Monge–Ampère PDE
  • Validate the transformed samples and the Jacobian calculation

The art

  • In \(d>1\), the proposal and target densities do not identify a unique map
  • Match the map family to the target’s support, dependence, and geometry
  • Choose coordinate ordering and the structure to preserve or simplify
  • Balance accuracy against fitting, inversion, Jacobian, and sampling costs

The density equation supplies the constraint

The designer supplies the structure that makes the map solvable and useful

A uniform proposal becomes a triangular target

Let the proposal and target densities be

\[ \varrho_{\mathrm{prop}}(z)=1,\quad 0<z<1, \qquad \varrho_{\mathrm{tar}}(x)=2x,\quad 0<x<1 \]

The target is \(\operatorname{Beta}(2,1)\) with \(F_{\mathrm{tar}}(x)=x^2\), so its quantile transport is

\[ T(z)=F_{\mathrm{tar}}^{-1}(z)=\sqrt z, \qquad X=T(Z),\quad Z\sim\Unif(0,1) \]

Indeed, for \(0<z<1\),

\[ \varrho_{\mathrm{tar}}\bigl(T(z)\bigr)T'(z) =2\sqrt z\,\frac{1}{2\sqrt z} =1 =\varrho_{\mathrm{prop}}(z) \]

Thus, for every integrable \(f\),

\[ \Ex_{\mathrm{tar}}[f(X)] =\Ex_{\mathrm{prop}}\!\left[f\bigl(\sqrt Z\bigr)\right] \]

A triangular flow creates curved dependence

Let \(Z_1,Z_2\ \IIDsim\ \Norm(0,1)\) and, for \(b>0\), define

\[ X_1=Z_1, \qquad X_2=Z_2+b(Z_1^2-1) \]

This nonlinear map is easy to invert and has a simple Jacobian:

\[ \vT_b^{-1}(\vx) =\begin{pmatrix}x_1\\x_2-b(x_1^2-1)\end{pmatrix}, \qquad \nabla \vT_b(\vz) =\begin{pmatrix}1&0\\2bz_1&1\end{pmatrix}, \qquad \det\nabla \vT_b=1 \]

Thus, with \(\phi\) the standard normal density,

\[ \varrho_{\mathrm{tar}}(x_1,x_2) =\phi(x_1)\phi\!\left(x_2-b(x_1^2-1)\right), \qquad \Ex(X_2\mid X_1=x_1)=b(x_1^2-1) \]

  • One flow layer: independent Gaussian coordinates \(\longrightarrow\) curved, dependent target
  • No useful map: acceptance–rejection sampling as another direct route

Acceptance–rejection sampling

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Ingredients

  • Proposal: sample \(\vZ\) from known density \(\varrho_{\mathrm{prop}}\)
  • Possibly unnormalized target: known \(\widetilde\varrho_{\mathrm{tar}}\)
    The desired \(\vX\) density is \(\varrho_{\mathrm{tar}}=c\widetilde\varrho_{\mathrm{tar}}\) for some \(c>0\)
  • Global envelope: known \(M\) with \(\widetilde\varrho_{\mathrm{tar}}(\vx)\le M\varrho_{\mathrm{prop}}(\vx)\) for all \(\vx\)

Sampler for \(\vX_0,\ldots,\vX_{n-1}\)

\[ \begin{aligned} &i\leftarrow0\\[-0.2em] &\texttt{repeat}\\[-0.2em] &\qquad \texttt{repeat}\quad \vZ\sim\varrho_{\mathrm{prop}},\quad V\sim\Unif[0,1] \quad\text{independently}\\[-0.2em] &\qquad \texttt{until}\quad V\le\frac{\widetilde\varrho_{\mathrm{tar}}(\vZ)} {M\varrho_{\mathrm{prop}}(\vZ)}\\[-0.2em] &\qquad \vX_i\leftarrow \vZ,\quad i\leftarrow i+1\\[-0.2em] &\texttt{until}\quad i=n \end{aligned} \]

No normalizing constant \(c\) needed

Why acceptance–rejection works

Acceptance indicator

\[ I:= \begin{cases} 1, & V\le \widetilde\varrho_{\mathrm{tar}}(\vZ)/ \bigl[M\varrho_{\mathrm{prop}}(\vZ)\bigr],\\ 0, & \text{otherwise} \end{cases} \]

Density of an accepted proposal

\[\begin{align*} \varrho_{\mathrm{tar}}(\vz) &=\varrho_{\vZ\mid I}(\vz\mid1)\\ &=\frac{\Prob(I=1\mid \vZ=\vz)\varrho_{\mathrm{prop}}(\vz)} {\Prob(I=1)} &&\text{by Bayes' theorem}\\ &=\frac{\left(\widetilde\varrho_{\mathrm{tar}}(\vz)/ \bigl[M\varrho_{\mathrm{prop}}(\vz)\bigr]\right) \varrho_{\mathrm{prop}}(\vz)} {\Prob(I=1)} &&\text{by the acceptance rule}\\ &=\frac{\widetilde\varrho_{\mathrm{tar}}(\vz)}{M\Prob(I=1)} =c\widetilde\varrho_{\mathrm{tar}}(\vz) &&\text{since }c\widetilde\varrho_{\mathrm{tar}}\text{ is a density} \end{align*}\]

  • Acceptance probability: \(\Prob(\text{acceptance})=\Prob(I=1)=1/(Mc)\)
  • Expected proposal cost: \(n(Mc)\) samples of \(\vZ\) for \(n\) samples of \(\vX\)

The same target by acceptance–rejection

Uniform proposal and triangular target · Notebook

\[ \frac{\varrho_{\mathrm{tar}}(z)} {\varrho_{\mathrm{prop}}(z)} =2z\le2 \]

  • Smallest envelope constant: \(M=2\)
  • Generate independent \(Z,V\sim\Unif(0,1)\)
  • Accept \(X=Z\) when

\[ V\le \frac{\varrho_{\mathrm{tar}}(Z)} {M\varrho_{\mathrm{prop}}(Z)} =Z \]

  • Acceptance probability: \(\Prob(\text{accept})=\Ex(Z)=1/2\)
  • Proposal cost: average \(2n\) proposals for \(n\) target samples
  • Exact transport: move every \(Z\) to \(\sqrt Z\)
  • Acceptance–rejection: keep \(Z\) with probability \(Z\)

Reframing Sampling as Unit-Cube Integration

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

One uniform input, with the last coordinate making the decision

\[\begin{gather*} (\vU,V)=(U_1,\ldots,U_d,U_{d+1})\sim\Unif[0,1]^{d+1}, \\ \vZ=\vS(\vU)\sim\varrho_{\mathrm{prop}} \end{gather*}\]

For numerical integration: points \((\vu_i,v_i)\in[0,1]^{d+1}\), \(i=0,\ldots,n-1\)
Use IID uniform draws or randomized low discrepancy points

Target expectations become integrals over \([0,1]^{d+1}\)

 

Low discrepancy sampling starts with uniform points in this cube; performance depends on the resulting integrand, including its decision boundary

Mixtures: choosing a component

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

For \(0<p<1\), let \(\vT_k(\vZ)\sim\varrho_k\) and define

\[\begin{gather*} C(V)=\begin{cases}1,&V\le p,\\2,&V>p,\end{cases} \qquad \vX=\vT_{C(V)}\bigl(\vS(\vU)\bigr) \end{gather*}\]

For every integrable \(f\),

\[\begin{align*} \Ex_{\mathrm{mix}}[f(\vX)] &=\int_{[0,1]^{d+1}} f\!\left(\vT_{C(v)}\bigl(\vS(\vu)\bigr)\right) \,\dif\vu\,\dif v\\ &=\int_{[0,1]^d}\left[ \int_0^p f\bigl(\vT_1(\vS(\vu))\bigr)\,\dif v +\int_p^1 f\bigl(\vT_2(\vS(\vu))\bigr)\,\dif v\right]\dif\vu\\ &=p\Ex_{\varrho_1}[f(\vX)]+(1-p)\Ex_{\varrho_2}[f(\vX)]\\ &\approx\frac1n\sum_{i=0}^{n-1} f\!\left(\vT_{C(v_i)}\bigl(\vS(\vu_i)\bigr)\right) \end{align*}\]

The decision coordinate \(V\) selects a component at the fixed threshold \(p\)

Acceptance–rejection: choosing which proposals to keep

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation

Target \(\varrho_{\mathrm{tar}}=c\widetilde\varrho_{\mathrm{tar}}\), with \(\widetilde\varrho_{\mathrm{tar}}\le M\varrho_{\mathrm{prop}}\); define

\[ a(\vz):=\frac{\widetilde\varrho_{\mathrm{tar}}(\vz)} {M\varrho_{\mathrm{prop}}(\vz)}, \qquad I_i:=\boldsymbol{1}\!\left\{v_i\le a\bigl(\vS(\vu_i)\bigr)\right\} \]

\[\begin{align*} \Ex_{\mathrm{tar}}[f(\vX)] &=\frac{\displaystyle\int_{[0,1]^{d+1}} f\bigl(\vS(\vu)\bigr)\boldsymbol{1}\!\left\{v\le a\bigl(\vS(\vu)\bigr)\right\} \,\dif\vu\,\dif v} {\displaystyle\int_{[0,1]^{d+1}} \boldsymbol{1}\!\left\{v\le a\bigl(\vS(\vu)\bigr)\right\} \,\dif\vu\,\dif v}\\ &\approx\frac{\displaystyle\frac1n\sum_{i=0}^{n-1}f\bigl(\vS(\vu_i)\bigr)I_i} {\displaystyle\frac1n\sum_{i=0}^{n-1}I_i} =\frac{\displaystyle\sum_{i:\,I_i=1}f\bigl(\vS(\vu_i)\bigr)} {\displaystyle\sum_{i=0}^{n-1}I_i} \end{align*}\]

Two sample means, same points; their quotient averages accepted proposals
Defined when at least one proposal is accepted

Big Ideas

Monte Carlo foundations, methods, and applications
(Quasi-)Random
Number Generation
  • Start with uniform samples and transform them to the target distribution
  • The generalized inverse works for discrete and continuous distributions
  • Independent marginal transforms do not create dependence
    Correlated normal vectors require a matrix factorization
    PCA can concentrate variation in early coordinates for low discrepancy sampling
  • Gaussian-process sampling reduces finite collections of function values to multivariate normal sampling
  • Option pricing: simulate asset paths, evaluate European, Asian, or barrier payoffs, and average discounted payoffs

Big Ideas (continued)

  • Low discrepancy points trade independent placement for more even coverage
  • Mixtures and acceptance–rejection express target expectations as integrals over \([0,1]^{d+1}\)
    Low discrepancy sampling acts on the uniform inputs; the component jump or acceptance boundary affects integration error
  • Exact transport moves every proposal point; acceptance–rejection keeps selected points using an unnormalized target and a global envelope

Companion GeneratingSamples notebook

From travel-time uncertainty to option pricing: transform random inputs into outputs whose means, probabilities, or quantiles answer the application question

What Comes Next

Direct methods turn uniform inputs into target samples, but a convenient transform or envelope may be hard to find

Markov Chain Monte Carlo takes a different route:

«
»