Selected Topics
November 23, 2026
Choose how to compute, optimize, search, and allocate
Evaluate different sample points on several processors to reduce elapsed time
Modern CPUs and GPUs can evaluate many operations concurrently
Parallelism changes computational cost
It does not repair biased estimators or poor sampling designs
The prepared laptop demonstration compares
Check the actual backend, include generation and evaluation, and synchronize GPU timing
A faster processor helps when the workload outweighs its overhead
End-to-end time determines the practical gain
Compare a baseline and a faster implementation: single-core / multicore CPU, or CPU / GPU
For fixed sampling method; runtime proportional to sample count
\[\begin{equation*} \left. \begin{aligned} s=\frac{\operatorname{time}_{\mathrm{baseline}}(n)}{\operatorname{time}_{\mathrm{faster}}(n)}>1 &\quad\implies\quad n_{\mathrm{faster}}\approx s\,n_{\mathrm{baseline}}\\ \operatorname{error}(n)\approx A n^{-p} &\quad\implies\quad \frac{\operatorname{error}(n_{\mathrm{faster}})}{\operatorname{error}(n_{\mathrm{baseline}})}\approx\frac1{s^p} \end{aligned} \right\} \quad\begin{gathered}\alerttext{for the same}\\\alerttext{time budget}\end{gathered} \end{equation*}\]
Error: RMSE for IID/RQMC; absolute-error bound for QMC
| Method | Power \(p\) | Conditions |
|---|---|---|
| IID | \(1/2\) | Finite contribution variance |
| QMC | \(\approx1\) | Sufficient smoothness and a suitable design |
| RQMC | \(\approx3/2\) | Sufficient smoothness and suitable scrambling |
Speedup \(s=16\): about \(1/4\) of the IID RMSE, \(1/16\) of the QMC bound, \(1/64\) of the RQMC RMSE
More outputs can improve throughput without improving accuracy per output
Combine many cheap coarse samples with fewer correction samples to reduce the cost of accurately estimating an expectation with high dimensional random input
The same notation works for \(L=2\) or many levels
| Symbol | Meaning |
|---|---|
| \(\ell\), \(L\) | Level index and finest included level |
| \(d_\ell\), \(f_{d_\ell}\) | Resolution and approximate output function |
| \(Y_\ell\) | Cheap output at level 1; fine output minus coarse output at later levels |
| \(\mu_\ell\), \(\hmu_\ell\) | Contribution mean \(\Ex(Y_\ell)\) and its estimate |
| \(\mu_{d_L}\) | Mean of the finest approximation: \(\sum_\ell\mu_\ell\) |
| \(V_\ell\) | IID contribution variance \(\var(Y_\ell)\) |
| Symbol | Meaning |
|---|---|
| \(n_\ell\), \(n=\sum_\ell n_\ell\) | Level sample count and total sample count |
| \(\$_\ell\) | Work for one complete contribution at level \(\ell\) |
| \(w_\ell\) | Sample allocation weight: \(n_\ell/n=w_\ell/\sum_k w_k\) |
Total work, for two or many levels
\[ C=n_1\$_1+n_2\$_2+\cdots+n_L\$_L =\sum_{\ell=1}^L n_\ell\$_\ell \]
\(C(\varepsilon)\) is the work needed at error tolerance \(\varepsilon\)
Sample counts and work shares differ
We want to compute \(\Ex\bigl[f_{d}(\vX_{1:d})\bigr]\) for large \(d\)
But large \(d\) costs more, e.g., \(\$\bigl(f_d(\vX_{1:d})\bigr)\propto d\)
Choose \(d_1\ll d_2=d\); couple the outputs to reduce the variance of their difference
\[\begin{align*} Y_1&=f_{d_1}(\vX_{1:d_1})& &\alerttext{cheap}\text{ approximation}\\ Y_2&=f_{d_2}(\vX_{1:d_2})-f_{d_1}(\vX_{1:d_1})& &\alerttext{expensive}\text{ correction} \end{align*}\]
\[ \mu=\Ex\{f_{d}(\vX_{1:d})\}=\Ex(Y_1)+\Ex(Y_2) \]
Estimate the cheap part often and the expensive correction less often, if its error is easier to control
Choose nested monitoring grids on \([0,T]\) with \(d_2=\kappa d_1\), \(\kappa>1\)
For an option, \(f_{d_\ell}(\vX_{1:d_\ell})\) computes its discounted payoff
using the path values at \(d_\ell\) monitoring times
\[\begin{align*} Y_1&=f_{d_1}(\vX_{1:d_1})&&\alerttext{cheap}\text{ coarse payoff}\\ Y_2&=f_{d_2}(\vX_{1:d_2})-f_{d_1}(\vX_{1:d_1})&&\alerttext{expensive}\text{ payoff correction} \end{align*}\]
Same path, two payoffs in \(Y_2\); aim for small variance of their difference
Estimate \(\mu_\ell=\Ex(Y_\ell)\) with uncorrelated level sample means: \(\operatorname{cov}(\hmu_1,\hmu_2)=0\)
Independent sample sets \(\{Y_{i,1}\}_{i=0}^{n_1-1}\) and \(\{Y_{i,2}\}_{i=0}^{n_2-1}\) ensure this condition
\[\begin{align*} \hmu&=\hmu_1+\hmu_2& \hmu_\ell&=\frac1{n_\ell}\sum_{i=0}^{n_\ell-1}Y_{i,\ell}\\ \var(\hmu)&=\var(\hmu_1)+\var(\hmu_2)& C&=n_1\$_1+n_2\$_2 \end{align*}\]
For unbiased level estimates, model \(\operatorname{RMSE}(\hmu_\ell)\approx A_\ell n_\ell^{-p}\)
\[ \operatorname{MSE}(\hmu) =\var(\hmu) \approx\frac{A_1^2}{n_1^{2p}}+\frac{A_2^2}{n_2^{2p}} \]
For independent unbiased random estimates, minimize the MSE model
\[ \frac{A_1^2}{n_1^{2p}}+\frac{A_2^2}{n_2^{2p}} \quad\text{subject to}\quad n_1\$_1+n_2\$_2=C \]
The optimal continuous allocation satisfies
\[ \frac{n_1}{n_2} =\left(\frac{A_1^2\$_2}{A_2^2\$_1}\right)^{1/(2p+1)} \]
IID (\(p=1/2\), \(A_\ell^2=V_\ell\)): sample allocation weights
\[ w_\ell=\frac{A_\ell}{\sqrt{\$_\ell}}=\sqrt{\frac{V_\ell}{\$_\ell}} \qquad\frac{n_1}{n_2}=\frac{w_1}{w_2} \qquad\frac{n_\ell}{n}=\frac{w_\ell}{w_1+w_2} \]
More points for larger error amplitude; fewer for larger cost per point
For the random case, treat \(n_1,n_2>0\) as continuous; fix total work \(C\)
\[ \underbrace{\mathcal L}_{\text{Lagrangian}} =\frac{A_1^2}{n_1^{2p}}+\frac{A_2^2}{n_2^{2p}} +\lambda(n_1\$_1+n_2\$_2-C) \]
\[\begin{align*} \frac{\partial\mathcal L}{\partial n_\ell}=0 &\implies\frac{2pA_\ell^2}{n_\ell^{2p+1}}=\lambda\$_\ell \qquad(\ell=1,2)\\ \frac{A_1^2}{\$_1n_1^{2p+1}} &=\frac{A_2^2}{\$_2n_2^{2p+1}} \implies\frac{n_1}{n_2} =\left(\frac{A_1^2\$_2}{A_2^2\$_1}\right)^{1/(2p+1)} \end{align*}\]
The sample allocation weights give
\[ w_\ell=\left(\frac{A_\ell^2}{\$_\ell}\right)^{1/(2p+1)} \qquad n_\ell=\frac{Cw_\ell}{\$_1w_1+\$_2w_2} =\frac{nw_\ell}{w_1+w_2} \]
At the optimum, each level buys the same marginal MSE reduction per unit work
Treat \(n_\ell>0\) as continuous; keep \(A_\ell,\$_\ell\) fixed
\[\begin{align*} \operatorname{MSE}_\ell&=\frac{A_\ell^2}{n_\ell} &\implies\quad \frac{\mathrm d\operatorname{MSE}_\ell}{\mathrm dn_\ell} &=-\frac{A_\ell^2}{n_\ell^2}\\ \operatorname{cost}_\ell&=n_\ell\$_\ell &\implies\quad \frac{\mathrm d\operatorname{cost}_\ell}{\mathrm dn_\ell}&=\$_\ell \end{align*}\]
The MSE decrease per unit work is the ratio of these derivatives
\[ -\frac{\mathrm d\operatorname{MSE}_\ell}{\mathrm d\operatorname{cost}_\ell} =-\frac{\mathrm d\operatorname{MSE}_\ell/\mathrm dn_\ell} {\mathrm d\operatorname{cost}_\ell/\mathrm dn_\ell} =\frac{A_\ell^2}{\$_\ell n_\ell^2} \]
Write \(\operatorname{err}_\ell^2=\operatorname{MSE}_\ell\) and \(w_\ell=A_\ell/\sqrt{\$_\ell}\)
\[ -\frac{\mathrm d\operatorname{MSE}_\ell}{\mathrm d\operatorname{cost}_\ell} =\frac{A_\ell^2}{\$_\ell n_\ell^2} =\frac{\operatorname{err}_\ell^2}{\operatorname{cost}_\ell} =\left(\frac{w_\ell}{n_\ell}\right)^2 \]
If one level has a larger value, moving a little work to it lowers total MSE
At the optimum, both derivative magnitudes equal \(\lambda\)
\[ \left(\frac{w_1}{n_1}\right)^2 =\left(\frac{w_2}{n_2}\right)^2=\lambda \implies\frac{n_1}{n_2}=\frac{w_1}{w_2} \]
Optimal allocation equalizes the MSE decrease per unit work
Use QMC separately for the same cheap part and coupled correction
Assume justified absolute-error bounds with a common \(p>0\)
\[\begin{align*} \abs{\hmu_\ell-\mu_\ell}&\le\frac{A_\ell}{n_\ell^p}\\ \abs{\hmu-\mu} &\le\abs{\hmu_1-\mu_1}+\abs{\hmu_2-\mu_2} \le\frac{A_1}{n_1^p}+\frac{A_2}{n_2^p} \end{align*}\]
At fixed work \(n_1\$_1+n_2\$_2=C\), minimize the bound
\[ w_\ell=\left(\frac{A_\ell}{\$_\ell}\right)^{1/(p+1)} \qquad\frac{n_1}{n_2}=\frac{w_1}{w_2} =\left(\frac{A_1\$_2}{A_2\$_1}\right)^{1/(p+1)} \]
QMC needs sufficient smoothness and a suitable design
Bound total error by the sum of the level error bounds
Two levels help when the cheap approximation and small correction error earn their combined cost
Fix grids, amplitudes, and costs; use the IID or RQMC model with common \(p>0\)
Scale the optimal counts together: \(n_1=t w_1\), \(n_2=t w_2\), \(t>0\)
From the optimal-weight definition: \(A_1^2=\$_1w_1^{2p+1}\) and \(A_2^2=\$_2w_2^{2p+1}\)
\[\begin{align*} S&=\$_1w_1+\$_2w_2 \qquad C=n_1\$_1+n_2\$_2=tS\\ \operatorname{MSE}(\hmu) &\approx\frac{A_1^2}{(tw_1)^{2p}}+\frac{A_2^2}{(tw_2)^{2p}}\\ &=\frac{\$_1w_1^{2p+1}}{t^{2p}w_1^{2p}} +\frac{\$_2w_2^{2p+1}}{t^{2p}w_2^{2p}} =\frac{\$_1w_1+\$_2w_2}{t^{2p}}=\frac{S}{t^{2p}} \end{align*}\]
\[ \operatorname{RMSE}(\hmu)\approx\frac{\sqrt S}{t^p}\approx\varepsilon \implies t\approx\left(\frac{\sqrt S}{\varepsilon}\right)^{1/p} \]
\[ C(\varepsilon)=tS \approx S\left(\frac{\sqrt S}{\varepsilon}\right)^{1/p} =S^{1+1/(2p)}\varepsilon^{-1/p} \]
Compare estimates of the same fine target \(\mu\) at RMSE \(\varepsilon\)
Direct fine contributions have variance \(V\) and complete per-sample work \(\$\)
\[ C_{\mathrm{single}}(\varepsilon)=\frac{V\$}{\varepsilon^2} \qquad C_{\mathrm{two}}(\varepsilon) =\frac{\left(\sqrt{V_1\$_1}+\sqrt{V_2\$_2}\right)^2}{\varepsilon^2} \]
With optimal two-level allocation, we save work precisely when
\[ \left(\sqrt{V_1\$_1}+\sqrt{V_2\$_2}\right)^2<V\$ \]
The same \(\varepsilon^{-2}\) factor cancels; compare the cost constants
On one shared path, the fine payoff is \(Y_1+Y_2\), so
\[ V=\var(Y_1+Y_2)=V_1+V_2+2\sqrt{V_1V_2}\corr(Y_1,Y_2) \]
Under these approximations,
\[ \frac{C_{\mathrm{two}}(\varepsilon)}{C_{\mathrm{single}}(\varepsilon)} \approx \left(\sqrt{\frac{\$_1}{\$_2}}+\sqrt{\frac{V_2}{V_1}}\right)^2 \]
Cheap coarse work and small correction variance can make this ratio less than one
Fix the grids and fine target; assume the same RMSE decay power \(p\)
\[ C_{\mathrm{single}}(\varepsilon)\propto\varepsilon^{-1/p} \qquad C_{\mathrm{two}}(\varepsilon)\propto\varepsilon^{-1/p} \]
| Either strategy | Halve the RMSE | Divide the RMSE by \(10\) |
|---|---|---|
| IID: \(p=1/2\) | \(4\times\) total work | \(100\times\) total work |
| Illustrative RQMC: \(p=1\) | \(2\times\) total work | \(10\times\) total work |
Two-level IID example: \(V_1=16\), \(V_2=1\), \(\$_1=1\), \(\$_2=16\)
\[ C_{\mathrm{two}}(\varepsilon)=64\varepsilon^{-2} \qquad C_{\mathrm{two}}(0.1)=6400\quad C_{\mathrm{two}}(0.05)=25600 \]
Here, two levels use less work if \(V\$>64\)
For independent IID level means, take \(p=1/2\) and total work \(C=3200\)
| Quantity | Cheap level 1 | Correction level 2 |
|---|---|---|
| Contribution variance \(V_\ell\) | \(16\) | \(1\) |
| Cost per contribution \(\$_\ell\) | \(1\) | \(16\) |
\(\exstar\) Find the optimal ratio \(n_1/n_2\) and the point counts \(n_1,n_2\) How much work goes to each level? Do fewer correction samples imply less correction work?
Multilevel Option Pricing — notebook · Open in Colab
More samples reduce integration error; finer grids address approximation bias
Repeat the two-level idea on grids \(d_1<d_2<\cdots<d_L\)
\[\begin{align*} Y_1&=f_{d_1}(\vX_{1:d_1})\\ Y_\ell&=f_{d_\ell}(\vX_{1:d_\ell}) -f_{d_{\ell-1}}(\vX_{1:d_{\ell-1}}),\qquad \ell\ge2 \end{align*}\]
The means telescope to the finest approximation
\[ \mu_{d_L}=\Ex\{f_{d_L}(\vX_{1:d_L})\} =\sum_{\ell=1}^L\Ex(Y_\ell) \]
One cheap approximation plus differences of coupled fine/coarse pairs
For an infinite-resolution target, distinguish the limit from the finest approximation
\[\begin{align*} \mu&=\lim_{d\to\infty}\Ex\{f_d(\vX_{1:d})\}\\ b_L&=\mu-\mu_{d_L} \qquad\text{remaining approximation bias} \end{align*}\]
Independent unbiased level estimates give \(\Ex(\hmu)=\mu_{d_L}\), so
\[ \operatorname{MSE}(\hmu)=b_L^2+\sum_{\ell=1}^L\var(\hmu_\ell) \]
At fixed \(L\), more samples cannot remove \(b_L\)
For IID, the same allocation result holds for any number of levels
\[ w_\ell=\sqrt{\frac{V_\ell}{\$_\ell}} \qquad \frac{n_\ell}{n}=\frac{w_\ell}{\sum_{k=1}^L w_k} \]
The optimum equalizes MSE reduction per unit work across levels
For a fixed finest grid, the optimal IID sampling cost is
\[ C(\varepsilon_{\mathrm s})=\frac{\left(\sum_{\ell=1}^L\sqrt{V_\ell\$_\ell}\right)^2}{\varepsilon_{\mathrm s}^2} \]
For total RMSE \(\varepsilon\), reserve \(\varepsilon_{\mathrm s}^2=\varepsilon^2-b_L^2>0\) for sampling error
Coupling helps when correction variances shrink fast enough to offset their higher cost
| To reduce | Change |
|---|---|
| Sampling error | Sample counts |
| Approximation bias | Finest grid |
Small fine-level terms in the sum can make extra resolution affordable
Now refine the final grid as the target RMSE \(\varepsilon\) shrinks to control approximation bias
Two examples: each refinement halves bias and makes a contribution cost \(4\times\) as much
| Correction variance per refinement | Most work | \(C(\varepsilon)\) |
|---|---|---|
| Divided by \(8\) | Coarse levels | \(\propto\varepsilon^{-2}\) |
| Divided by \(2\) | Fine levels | \(\propto\varepsilon^{-3}\) |
The cost exponent depends on how fast correction variance falls compared with growing work and required refinement
Compare the option-pricing notebook and beam notebook to inspect allocation and bias
Sample a few observations per update for cheap optimization moves, while controlling gradient noise
Choose \(m\) parameters \(\vtheta\) to make loss small
\[\begin{equation*} \vtheta_*\in\argmin_{\vtheta\in\reals^m}\operatorname{Loss}(\vtheta) \end{equation*}\]
Optimization usually needs many moves; compare their total cost
For one parameter, approximate the loss near the current \(\theta\)
\[\begin{equation*} q(s)=\operatorname{Loss}(\theta)+g s+\tfrac12 h s^2 \qquad g=\operatorname{Loss}'(\theta),\quad h=\operatorname{Loss}''(\theta) \end{equation*}\]

Newton chooses \(s=-g/h\) when \(h>0\); then rebuild the local model
| Challenge | What changes? | Consequence for optimization |
|---|---|---|
| Nonquadraticity | Curvature changes with position | Refresh the local model; shorten or safeguard a proposed step |
| Nonconvexity | A stationary point need not be globally optimal | Try multiple starts and compare losses; no global guarantee |
Rebuild local models and compare starting points; local information has limits
\[\begin{gather*} \vg_k=\nabla\operatorname{Loss}(\vtheta_k) \qquad \mH_k=\nabla^2\operatorname{Loss}(\vtheta_k) \\ \vtheta_{k+1}=\vtheta_k-\eta_k\vg_k \qquad \eta_k>0\text{ is the learning rate} \end{gather*}\]
| Method | Direction | Generic dense storage / solve |
|---|---|---|
| Gradient descent | \(-\eta_k\vg_k\) | \(m\) gradient entries; no Hessian solve |
| Newton | Solve \(\mH_k\vs=-\vg_k\) | \(O(m^2)\) storage; \(O(m^3)\) solve |
| Method | Information used | When to consider it |
|---|---|---|
| Downhill simplex (Nelder–Mead) | Loss at \(m+1\) vertices | Modest \(m\); derivatives unavailable |
| Newton / trust-region | Gradients and curvature | Affordable local models |
| BFGS / L-BFGS | Gradients and previous steps | Curvature without a full Hessian |
| Momentum / accelerated gradient | Gradients and past motion | Improve first-order progress |
Choose a direction method, then ask how much each move costs
| Feature | Meaning | Practical response |
|---|---|---|
| Nonquadraticity | Curvature changes as we move | Recompute directions; safeguard steps |
| Nonconvexity | Zero gradient need not mean a global minimum | Compare starts; no general global guarantee |
| Poor conditioning | Curvature differs greatly by direction | Scale, precondition or use curvature |
For a convex loss, a zero gradient identifies a global minimizer
For a quadratic loss with positive-definite Hessian \(\mH\)
\(\kappa(\mH)=\lambda_{\max}(\mH)/\lambda_{\min}(\mH)\) measures conditioning
Cheap moves help with cost; they do not remove difficult geometry
\[R(\vtheta)=(1-\theta_1)^2+100(\theta_2-\theta_1^2)^2 \qquad \vtheta_*=(1,1)^\top\]

Unequal and changing curvature can slow GD even with only two parameters

At the minimizer: \(m=2\), \(\kappa\approx2508\)
Every dot is one accepted GD update
Sampling makes gradients cheaper; it does not remove poor conditioning
| Challenge | What changes? | Consequence for optimization |
|---|---|---|
| Nonquadraticity | Curvature changes with position | Refresh the local model; shorten or safeguard a proposed step |
| Nonconvexity | A stationary point need not be globally optimal | Try multiple starts and compare losses; no global guarantee |
| Hessian cost | Dense storage \(O(m^2)\); solve \(O(m^3)\) | Use first-order or limited-memory methods when full curvature costs too much |
| Conditioning | Curvature differs across directions | Scale or precondition variables; consider curvature information |
First-order methods save Hessian work; the geometry still affects convergence
With \(N\) observations, a common objective is a finite average
\[\begin{equation*} \operatorname{Loss}(\vtheta)=\frac1N\sum_{i=0}^{N-1}\operatorname{loss}_i(\vtheta) \end{equation*}\]
For dense regression models with \(m\) parameters
| Calculation | Direct work |
|---|---|
| One observation’s loss or gradient | \(O(m)\) |
| Full loss or full gradient | \(O(Nm)\) |
Many full-data moves mean many expensive passes
Could we sample the \(\operatorname{loss}_i\) terms rather than average all \(N\) at every move?
| Challenge | What changes? | Consequence for optimization |
|---|---|---|
| Nonquadraticity | Curvature changes with position | Refresh the local model; shorten or safeguard a proposed step |
| Nonconvexity | A stationary point need not be globally optimal | Try multiple starts and compare losses; no global guarantee |
| Hessian cost | Dense storage \(O(m^2)\); solve \(O(m^3)\) | Use first-order or limited-memory methods when full curvature costs too much |
| Conditioning | Curvature differs across directions | Scale or precondition variables; consider curvature information |
| Full-gradient cost | Direct data pass \(O(Nm)\) | Reuse structure or sample fewer terms; small \(m\) can still favor Newton |
First-order methods save Hessian work; sampling can reduce full-gradient work
Full gradient: \(\vg_k=\nabla\operatorname{Loss}(\vtheta_k)\); sampled estimate: \(\vG_k\)
Sample \(b\) loss terms using fresh IID indices \(I_{k0},\ldots,I_{k,b-1}\) uniform on \(\{0,\ldots,N-1\}\)
\[\begin{gather*} \vG_k=\frac1b\sum_{j=0}^{b-1}\nabla\operatorname{loss}_{I_{kj}}(\vtheta_k) \\ \vtheta_{k+1}=\vtheta_k-\eta_k\vG_k \qquad \Ex[\vG_k\mid\vtheta_k]=\vg_k \end{gather*}\]
Differentiate the sampled loss terms, average their gradients, then take a cheap update
One uniform \(U\sim\Unif[0,1)\) selects one whole observation: \(I=\lfloor NU\rfloor\)
\[\begin{gather*} \widetilde{\vg}_{\vtheta}(u)=\nabla\operatorname{loss}_{\lfloor Nu\rfloor}(\vtheta) \\ \int_0^1\widetilde{\vg}_{\vtheta}(u)\,\dif u =\nabla\operatorname{Loss}(\vtheta) \qquad \vG_k=\frac1b\sum_{j=0}^{b-1}\widetilde{\vg}_{\vtheta_k}(U_{kj}) \end{gather*}\]
| Count | Meaning |
|---|---|
| \(N\) | Observations in the fixed dataset |
| \(m\) | Entries in each gradient; parameters we update |
| \(b=d\) | Independent indices in one mini-batch; dimension of the draw |
Sample observation indices; average their \(m\)-component gradients
Appropriate learning rates and GD’s convergence conditions still matter
Judge similarity by gradients; compare sampling noise with the full-gradient signal
For \(\operatorname{loss}_i(\theta)=\tfrac12(\theta-a_i)^2\), with \(a_i=\pm1\) equally often
\[\begin{equation*} \operatorname{Loss}(\theta)=\tfrac12(\theta^2+1) \qquad \theta_*=0 \qquad \operatorname{Loss}'(0)=0 \end{equation*}\]
At \(0\), every component loss is \(1/2\), but the gradients are \(+1\) and \(-1\)
Do not wait for each sampled gradient to become zero
| Challenge | What changes? | Consequence for optimization |
|---|---|---|
| Nonquadraticity | Curvature changes with position | Refresh the local model; shorten or safeguard a proposed step |
| Nonconvexity | A stationary point need not be globally optimal | Try multiple starts and compare losses; no global guarantee |
| Hessian cost | Dense storage \(O(m^2)\); solve \(O(m^3)\) | Use first-order or limited-memory methods when full curvature costs too much |
| Conditioning | Curvature differs across directions | Scale or precondition variables; consider curvature information |
| Full-gradient cost | Direct data pass \(O(Nm)\) | Reuse structure or sample fewer terms; small \(m\) can still favor Newton |
| Gradient noise | Random direction estimates | Use mini-batches, smaller steps or averaging for finer accuracy |
Toy objective: \(m=2\) parameters, average of \(N=1{,}000\) loss terms
Equal component-gradient work: 45 GD moves versus 4,500 mini-batch moves
45,000 contributions each: 1,000 per GD move; 10 per SGD move (\(b=10\))
Common rate \(\eta=0.5\); picture shows first 60 mini-batch moves (600 contributions)

Use periodic evidence to guide the run; small movement alone is weak evidence
For \(K\) updates, \(J_s\) diagnostic checks and \(J_N\) full-loss checks
\[\begin{equation*} \text{direct training work}=O\bigl(m(Kb+J_s s+J_N N)\bigr) \end{equation*}\]
| Check | Cost | Purpose |
|---|---|---|
| Loss on the same \(s\) randomly selected observations | \(O(sm)\) | Estimate training-loss progress |
| Full training loss | \(O(Nm)\) | Measure the empirical objective |
| Held-out validation loss | Depends on validation size | Check predictive performance |
Pay for checks after many moves, with cheaper diagnostics between
Full gradient: \(\vg_k=\nabla\operatorname{Loss}(\vtheta_k)\); sampled update direction: \(\vG_k\)
Choose a stationarity target \(\norm{\vg_k}\leq\tau\), with \(\tau>0\)
| Evidence at a checkpoint | What can we conclude? |
|---|---|
| Tiny move or loss plateau | May reflect a small rate or unresolved noise |
| Full-gradient norm at most \(\tau\) | The stationarity target is met; costs \(O(Nm)\) |
| Sampled \(\vG_k\) | Its norm plus justified uncertainty must be at most \(\tau\) |
Binary observation \(y_i\in\{0,1\}\); predictor \(z_i=\vx_i^\top\vtheta\)
\[\begin{gather*} p_i(\vtheta)=\Prob_{\vtheta}(Y_i=1\mid\vx_i) =\frac{1}{1+e^{-z_i}} \end{gather*}\]
| Observed label | Probability assigned to that label |
|---|---|
| \(y_i=1\) | \(p_i\) |
| \(y_i=0\) | \(1-p_i\) |
Combine the two cases: \(q_i(\vtheta)=p_i^{y_i}(1-p_i)^{1-y_i}\)
For independent labels, maximize their likelihood
\[\max_{\vtheta}\prod_i q_i(\vtheta) \quad\Longleftrightarrow\quad \min_{\vtheta}\sum_i[-\log q_i(\vtheta)]\]
The negative log likelihood for one observation is
\[\ell_i^{\mathrm{data}}=-\log q_i =-y_i\log p_i-(1-y_i)\log(1-p_i)\]
Substitute \(p_i=e^{z_i}/(1+e^{z_i})\)
\[\begin{align*} \log p_i&=z_i-\log(1+e^{z_i})\\ \log(1-p_i)&=-\log(1+e^{z_i}) \end{align*}\]
Therefore
\[\begin{align*} \ell_i^{\mathrm{data}} &=-y_i z_i+[y_i+(1-y_i)]\log(1+e^{z_i})\\ &=\log(1+e^{z_i})-y_i z_i \end{align*}\]
At \(p_i=0.9\): loss \(0.105\) for label 1; loss \(2.303\) for label 0
Add a separate quadratic penalty to the mean data loss
\[F(\vtheta)=\frac1N\sum_{i=0}^{N-1}\ell_i^{\mathrm{data}}(\vtheta) +\frac\lambda2\norm{\vtheta}^2\]
First differentiate with respect to \(z_i=\vx_i^\top\vtheta\)
\[\frac{\dif\ell_i^{\mathrm{data}}}{\dif z_i} =\frac{e^{z_i}}{1+e^{z_i}}-y_i=p_i-y_i\]
With \(\operatorname{loss}_i=\ell_i^{\mathrm{data}}+(\lambda/2)\norm{\vtheta}^2\), the chain rule gives
\[\nabla\operatorname{loss}_i(\vtheta) =(p_i-y_i)\vx_i+\lambda\vtheta\]
Let \(X\) have rows \(\vx_i^\top\); the notebook uses the global curvature bound
\[L_{\mathrm{bound}}=\lambda_{\max}\!\left(\frac{X^\top X}{4N}\right)+\lambda\]
| Method | Implemented learning rate |
|---|---|
| Full GD | \(1/L_{\mathrm{bound}}\), computed once for the fixed dataset |
| Fixed mini-batch SGD | \(\eta=0.3\) |
| Decaying single-observation or mini-batch SGD | \(\eta(w)=0.3/(1+w/(0.25N))\) |
One fixed logistic dataset: \(N=262{,}144\), \(m=20\), \(b=256\), \(s=1{,}024\)
Loss gap: \(\operatorname{Loss}(\vtheta)-\operatorname{Loss}(\vtheta_*)\)
One equivalent pass: \(N\) observation-gradient contributions
Median passes to the first recorded target crossing
| Loss-gap target | Full GD | Fixed SGD | Decaying SGD |
|---|---|---|---|
| \(10^{-3}\) — useful answer | \(2\) | \(0.059\) | \(0.066\) |
| \(10^{-4}\) | \(3\) | — | \(2.04\) |
| \(10^{-6}\) — finer answer | \(6\) | — | — |
Same average loss; both choose a direction and a learning rate
| Feature | Full GD | Mini-batch SGD |
|---|---|---|
| Direction | Full gradient \(\vg_k\) | Sampled \(\vG_k\): unbiased, noisy |
| Learning rate, \(\eta_k\) | Curvature bound, or full-loss backtracking | Short pilots; then use a fixed or decaying schedule |
| Update work | All \(N\) terms: \(O(Nm)\) | Sample \(b\) terms: \(O(bm)\) |
| Total work | \(O(K_{\mathrm{GD}}Nm)+C_{\mathrm{GD}}\) | \(O(K_{\mathrm{SGD}}bm)+C_{\mathrm{SGD}}\) |
| Near minimum | \(\vg_k\) approaches zero | Noise can persist at fixed \(b\) |
| Reduce noise effect | No sampling noise | Smaller steps, larger batches or variance reduction |
| Check progress | Full-gradient norm or loss | Periodic checks with noise assessment |
\(K\): each method’s updates to the target; \(C\): setup, tuning and all checking work
Both face difficult geometry; compare total work and time at the same accuracy
| Research direction | Contribution | Link to SGD |
|---|---|---|
| Derivative-free optimization | Rates and limits for gradient estimates from function values | Randomness can estimate a direction without derivatives |
| Accelerated methods | A variational, continuous-time framework | Understand and design methods using momentum |
| Escape from saddle points | Guarantees for deliberately perturbed gradient descent | Randomness can also help leave a saddle |
Sampling data, estimating derivatives, and perturbing iterates serve different purposes
Open Stochastic Gradient Descent on GitHub · Run in Colab
\(\exstar\) Increase \(N\) with \(m\) fixed; then tighten the requested accuracy When do cheap updates help, and when does noise limit useful progress?
Simulate possible futures to focus a limited search budget on promising actions
Choose an airport itinerary before departure; traffic makes arrival uncertain
| Application | Search decisions | Good outcome |
|---|---|---|
| AlphaGo and AlphaZero | Legal moves in Go; also chess and shogi for AlphaZero | Win the game |
| Navigation | Sailing directions under uncertain wind | Reach the destination at low travel cost |
| Traveling salesperson | Choose the next unvisited city | Short tour through every city and back to start |
| AlphaTensor | Steps in a matrix multiplication algorithm | Correct result with fewer scalar multiplications |
MCTS allocates search effort among sequences of decisions
The notebook declares synthetic segment distributions in minutes
| First road | Base time | Extra delay | Delay probability |
|---|---|---|---|
| A · North | 10 | 26 | 0.35 |
| B · Central | 13 | 13 | 0.22 |
| C · South | 16 | 7 | 0.10 |
For North’s first segment, \[\begin{equation*} T_A=\begin{cases}10 & \text{with probability }0.65\\36 & \text{with probability }0.35\end{cases} \end{equation*}\]
For a complete plan \(p\), simulate its total travel time \(T(p)\) in minutes
With deadline \(D=80\) minutes, record the return
\[\begin{equation*} R=\begin{cases}1 & \text{arrive by the deadline}\\0 & \text{arrive late}\end{cases} \qquad \mu(p)=\Ex(R)=\Prob\bigl(T(p)\leq D\bigr) \end{equation*}\]
At a stored node \(s\), keep successes \(W(s)\) and visits \(N(s)\)
\[\begin{equation*} \overline Q(s)=\frac{W(s)}{N(s)} \qquad \frac{28\text{ on-time trips}}{40\text{ simulations}}=0.70 \end{equation*}\]
A branch’s average summarizes the continuations tried so far
Chess has deterministic moves; this toy game shows why replies matter
One MCTS iteration: run all four steps in order
| Step | In one iteration |
|---|---|
| Select | Follow highest-scoring stored choices until reaching a node with an untried action, or a complete plan |
| Expand | Store one untried child, if available |
| Roll out | Sample remaining choices without storing their nodes; simulate traffic for \(R\) |
| Back up | Update visits and returns for the selected stored nodes and the one new node; discard the rollout suffix |
Repeat until the search budget is exhausted
Here each iteration uses one traffic simulation; a search run uses the whole budget
Keep the selected path and any newly expanded node
Discard the rollout suffix; retain its return in the counters
The full rollout gives one sampled return for the new route prefix
The stored nodes keep the return from the complete simulated trip
UCT: Upper Confidence Bounds applied to Trees
At partial plan \(s\), score a visited next road choice \(a\)
\[\begin{equation*} \underbrace{\overline Q(s,a)}_{\text{exploit a high average}} +\underbrace{c\sqrt{\frac{\log N(s)}{N(s,a)}}}_{\text{explore a less-visited branch}} \qquad c>0 \end{equation*}\]
Expand an untried action first
Otherwise select the largest score
Following example: \(c=1\), natural \(\log\)
For action \(a\), use the counts in the child box reached from \(s\)
Probability bounds for mean rewards motivate the exploration bonus
A smaller teaching tree
Simulate a trip, then record
\[\begin{equation*} R=\begin{cases} 1 & T\leq80\text{ minutes}\\ 0 & T>80\text{ minutes} \end{cases} \end{equation*}\]
Initially, only the root is stored
Each iteration restarts at Start
At most one new node; roll out the suffix
Before: \(N(\text{Start})=0\)
Both actions are untried — no UCT comparison
Only one new node stored
The dashed continuation is sampled, then discarded
Before: \(N(\text{Start})=1\)
B is untried — no UCT comparison
Try untried actions first
A stays at 1/1
Next: restart at Start and compare UCT scores
\(c=1\) for this example
Select (before backup) \(N(\text{Start})=2\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 1 | 1 | 1.833 |
| B | 0 | 1 | 0.833 |
Expand: A–0, using untried 0
Roll out: 1, 0, \(T=78\), \(R=1\)
Back up: update Start, A, A–0
and discard the dashed suffix
Select (before backup) \(N(\text{Start})=3\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 2 | 2 | 1.741 |
| B | 0 | 1 | 1.048 |
Expand: A–1, using untried 1
Roll out: 0, 0, \(T=79\), \(R=1\)
Back up: update Start, A, A–1
and discard the dashed suffix
Select (before backup) \(N(\text{Start})=4\), \(N(A)=3\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 3 | 1.680 |
| B | 0 | 1 | 1.177 |
| A–0 | 1 | 1 | 2.048 |
| A–1 | 1 | 1 | 2.048 |
Expand: A–0–0, using untried 0
Roll out: 0, \(T=86\), \(R=0\)
Back up: update Start, A, A–0, A–0–0
and discard the dashed suffix
Select (before backup) \(N(\text{Start})=5\), \(N(A)=4\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 4 | 1.384 |
| B | 0 | 1 | 1.269 |
| A–0 | 1 | 2 | 1.333 |
| A–1 | 1 | 1 | 2.177 |
Expand: A–1–0, using untried 0
Roll out: 0, \(T=85\), \(R=0\)
Back up: update Start, A, A–1, A–1–0
and discard the dashed suffix
One path down resembles depth-first search
Breadth-first search grows level by level
Here A–0–0 (depth 3) came before B–0 (depth 2)
Select (before backup) \(N(\text{Start})=6\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 5 | 1.199 |
| B | 0 | 1 | 1.339 |
Expand: B–0, untried 0 at B
Roll out: 1, 0, \(T=76\), \(R=1\)
Back up: update Start, B, B–0
and discard the dashed suffix
Select (before backup) \(N(\text{Start})=7\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 5 | 1.224 |
| B | 1 | 2 | 1.486 |
Expand: B–1, untried 1 at B
Roll out: 0, 0, \(T=86\), \(R=0\)
Back up: update Start, B, B–1
and discard the dashed suffix
Select (before backup) \(N(\text{Start})=8\), \(N(A)=5\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 5 | 1.245 |
| B | 1 | 3 | 1.166 |
| A–0 | 1 | 2 | 1.397 |
| A–1 | 1 | 2 | 1.397 |
Expand: A–0–1, untried 1 at A–0
Roll out: 0, \(T=84\), \(R=0\)
Back up: update Start, A, A–0, A–0–1
and discard the dashed suffix
B–0–1 was rollout-only in iteration 7 and becomes a stored node here
Select (before backup) \(N(\text{Start})=9\), \(N(B)=3\)
\[\begin{equation*} \operatorname{UCT}(s,a)=\frac{W(s,a)}{N(s,a)} +\sqrt{\frac{\log N(s)}{N(s,a)}} \end{equation*}\]
| Child | \(W(s,a)\) | \(N(s,a)\) | UCT |
|---|---|---|---|
| A | 3 | 6 | 1.105 |
| B | 1 | 3 | 1.189 |
| B–0 | 1 | 1 | 2.048 |
| B–1 | 0 | 1 | 1.048 |
Expand: B–0–1, untried 1 at B–0
Roll out: 0, \(T=78\), \(R=1\)
Back up: update Start, B, B–0, B–0–1
and discard the dashed suffix
During search
After the budget
The first road in the recommendation is A with 6 visits, compared with 4 for B
Build the itinerary using the counts after the tenth backup
| Current prefix | Stored children | Next choice |
|---|---|---|
| Start | A: 6 visits, B: 4 visits | A has more visits |
| A | A–0: 3 visits, A–1: 2 visits | 0 has more visits |
| A–0 | Each child has \(W/N=0/1\) | 0 comes first in a tie |
| A–0–0 | No stored child | 0 fills the final choice |
Recommended itinerary: A–0–0–0
Open Monte Carlo Tree Search on GitHub · Run in Colab
\(\exstar\) Change the simulation budget or exploration weight \(c\) Does a high early success rate always identify the best complete plan?
From Monte Carlo estimates to computational design
Good simulation balances accuracy, computational cost, and evidence for stopping
Bring the course methods together in a concrete model or project:
The next step is a defensible end-to-end simulation
© 2026 Fred J. Hickernell · Illinois Tech · assisted by ChatGPT and Codex · Selected Topics · MATH 565 — Fall 2026 Website · \(\exstar\) = exercise