Quiz: stochastic differential equations
Short questions to test your understanding of stochastic differential equations. Try each on paper first, then open the answer.
Q1. A student builds Brownian motion on \([0, 1]\) from \(1/h\) steps of \(\pm h\) instead of \(\pm\sqrt h\). What is the variance of the end point for \(h = 0.001\)? What goes wrong as \(h \to 0\)?
Variances of independent steps add.
\(1000\) steps of variance \(h^2 = 10^{-6}\): variance \(10^{-3}\), instead of 1. In general the variance is \(h\), which goes to 0: the walk stops moving and the limit is a straight line, not Brownian motion. Only steps of size \(\sqrt h\) (variance \(h\) each) keep the variance at time \(t\) equal to \(t\) for every \(h\).
Q2. A bead is tracked in 2D. Its MSD is \(1.7\) µm² at a lag of 1 s and grows linearly. What is \(D\)? The same bead tracked only in \(x\) would have which MSD at 1 s?
\(\text{MSD} = 2dDt\) with \(d\) the number of dimensions.
\(D = 1.7/(4 \cdot 1) = 0.43\) µm²/s, the Stokes–Einstein value for a bead of radius 0.5 µm in water at 20 °C. In 1D, \(\text{MSD} = 2Dt = 0.85\) µm²: each coordinate contributes half.
Q3. One Euler–Maruyama step for a population, \(dN = 0.5\,N\,dt + 0.4\,N\,dW\), from \(N_0 = 200\) with \(h = 0.01\) and \(Z = -1\). What is \(N_1\)? Which part of the step is larger, the drift or the kick?
\(N_1 = N_0 + f(N_0)\,h + g(N_0)\sqrt h\,Z\).
Drift \(0.5 \cdot 200 \cdot 0.01 = 1\); kick \(0.4 \cdot 200 \cdot 0.1 \cdot (-1) = -8\). \(N_1 = 200 + 1 - 8 = 193\). The kick is 8 times larger: it scales with \(\sqrt h = 0.1\), the drift with \(h = 0.01\).
Q4. Strong or weak error: which one matters for (a) the mean protein level over a population of simulated cells, (b) the probability that an outbreak dies out, (c) reconstructing the path of one tracked bead from the noise that drove it, (d) a convergence test that compares a coarse and a fine simulation path by path?
Weak error concerns distributions and averages; strong error concerns single paths.
- and (b): weak. A mean and a probability are averages over the distribution; EM’s weak order 1 applies. (c) and (d): strong. They need each simulated path to be close to the exact path driven by the same noise; EM’s strong order is only ½ for multiplicative noise.
Q5. EM on geometric Brownian motion has a strong error of 0.040 at \(h = 1/64\). What do you expect at \(h = 1/256\)? And for Milstein, if its error at \(h = 1/64\) is 0.015?
Error \(\approx C h^p\). Dividing \(h\) by 4 divides the error by \(4^p\).
EM, \(p = \tfrac12\): \(0.040/2 = 0.020\) (the lecture measured 0.0199). Milstein, \(p = 1\): \(0.015/4 = 0.0037\) (measured 0.0037). To gain a factor 10 in strong accuracy, EM needs a 100 times smaller step, Milstein 10 times.
Q6. A convergence test of EM prints strong errors 1.20, 1.22, 1.23, 1.22 for \(h = 1/16, 1/64, 1/256, 1/1024\). What is the most likely bug, and how do you fix it?
What would the strong error be if the numerical and the “exact” solution belonged to two unrelated paths?
The coarse runs use fresh random increments instead of the same Brownian path as the exact solution. Then the “error” is the distance between two independent random populations, which does not shrink with \(h\). Fix: draw the fine increments once and build each coarse increment as the sum of the fine increments inside the coarse step.
Q7. A colleague tests her EM code on the Ornstein–Uhlenbeck process \(dX = -\theta X\,dt + \sigma\,dW\) and measures strong order 1, not ½. Is her code wrong?
Write down the Milstein correction for constant \(g\).
No. With additive noise (\(g = \sigma\) constant) the Milstein term \(\frac12 g g'(\Delta W^2 - h)\) is zero, so EM is the Milstein method and has strong order 1. Order ½ shows only for multiplicative noise (\(g\) depending on \(X\)). A test of strong order ½ should use, for example, geometric Brownian motion.
Q8. A population has \(dN = rN\,dt + \sigma N\,dW\) with \(r = 0.05\) per year and \(\sigma = 0.5\) per \(\sqrt{\text{year}}\). Does the mean grow? Does a typical population grow? After 20 years, what are the mean and the median relative to the start?
Mean \(N_0e^{rt}\), median \(N_0e^{(r - \sigma^2/2)t}\).
The mean grows: \(e^{0.05 \cdot 20} = e^1 = 2.72\) times the start. But \(r - \sigma^2/2 = 0.05 - 0.125 = -0.075\), so the median shrinks: \(e^{-1.5} = 0.22\) times the start. Most populations decline and many go (quasi-)extinct, while a few lucky ones carry the mean. This is the Itô correction: \(\log N\) grows at \(r - \sigma^2/2\), because the squared kicks \((\Delta W)^2 \approx h\) do not average out.
Q9. EM for the optical trap, \(x_{n+1} = (1 - \theta h)x_n + \sigma\sqrt h\,Z_n\), has stationary variance \(\sigma^2/(\theta(2 - \theta h))\) instead of \(\sigma^2/(2\theta)\). With \(\theta = 1\) per ms, which step gives a 1% error in the variance? What happens at \(h = 2\) ms?
The ratio of the two variances is \(2/(2 - \theta h) \approx 1 + \theta h/2\).
\(\theta h/2 = 0.01\): \(h = 0.02\) ms. At \(\theta h = 2\) the variance is infinite: the factor \(1 - \theta h = -1\) no longer damps anything (Euler’s stability limit). For this linear model the exact recursion \(x_{n+1} = e^{-\theta h}x_n + \sqrt{\tfrac{\sigma^2}{2\theta}(1 - e^{-2\theta h})}\,Z_n\) has no error at any \(h\).
Q10. For \(dC = -2\,C\,dt + C\,dW\) (per hour), Euler for the ODE \(C' = -2C\) is stable for \(h < 1\) h. Is EM with \(h = 0.5\) h mean-square stable? What about drift-implicit EM?
EM: \(\mathrm E\,C_{n+1}^2 = \big((1 - kh)^2 + \mu^2 h\big)\,\mathrm E\,C_n^2\). Drift-implicit: \((1 + \mu^2h)/(1 + kh)^2\).
EM: \((1 - 1)^2 + 0.5 = 0.5 < 1\): stable. (It is stable for \((1 - 2h)^2 + h < 1\), i.e. \(h < 0.75\) h, a smaller range than the ODE’s \(h < 1\).) Drift-implicit: \(1.5/4 = 0.375\), and below 1 for every \(h\). The exact SDE is mean-square stable because \(2 \cdot (-2) + 1^2 = -3 < 0\).
Q11. Write the Fokker–Planck equation for \(dX = -\theta X\,dt + \sigma\,dW\) as an advection–diffusion equation. What are the velocity and the diffusion coefficient, and what is the steady state?
Velocity \(u = f\), diffusion coefficient \(D = g^2/2\). At steady state the total flux \(u\,p - D\,\partial p/\partial x\) is zero.
\(\dfrac{\partial p}{\partial t} = -\dfrac{\partial}{\partial x}\Big(-\theta x\,p - \dfrac{\sigma^2}{2}\dfrac{\partial p}{\partial x}\Big)\): velocity \(u(x) = -\theta x\) (towards 0 from both sides), \(D = \sigma^2/2\). Zero flux: \(-\theta x\,p = D\,p'\), so \(p \propto e^{-\theta x^2/(2D)}\), a normal density with variance \(D/\theta = \sigma^2/(2\theta)\), the stationary OU variance. Numerically, the cell Péclet number \(|u|\Delta x/D\) decides between central and upwind differences for the drift, and upwind adds numerical diffusion \(\approx |u|\Delta x/2\) that widens the density.
Q12. A toggle switch is reduced to one variable with two stable states at \(x = \pm 1\): \(dX = (X - X^3)\,dt + \sigma\,dW\). Starting at \(-1\), simulations (2000 paths, \(h = 0.01\)) take on average about 40 time units to reach \(+1\) when \(\sigma = 0.5\) and about 300 when \(\sigma = 0.35\). A run of 50 time units with \(\sigma = 0.35\) shows no switch. Can you conclude that the switch is stable? What does the ODE say, and what happens for \(\sigma = 0.25\)?
The mean switching time grows roughly like \(e^{2\Delta V/\sigma^2}\), where \(\Delta V = 1/4\) is the height of the barrier between the two wells of the potential \(V(x) = -x^2/2 + x^4/4\).
No. Switching is a rare event: with a mean time of about 300, one run of 50 time units sees a switch only with probability of about 15%. The ODE (\(\sigma = 0\)) never switches: each stable state of Equilibria, stability and the phase plane keeps its basin forever. The noise-induced switching time grows exponentially as \(\sigma\) decreases: \(e^{0.5/\sigma^2}\) gives a factor \(e^{4.08 - 2} = 8\) from \(\sigma = 0.5\) to \(0.35\) (simulated: \(300/40 = 7.5\)) and another \(e^{8 - 4.08} \approx 50\) to \(\sigma = 0.25\), so about 15 000 time units. Estimating such times by brute-force simulation gets expensive quickly: long runs, many paths, and a step \(h\) small enough for the drift; that is a rare-event problem as in Random numbers and Monte Carlo.