Skip to content
Work Practice Products Coding interviews Machine learning coding Quant developer HFT course Blog Method Why me About Enquire Book a call

Blog · Quant interviews

How to solve a stochastic differential equation: the four moves quant interviews test

Almost no SDE has a closed-form solution, and the ones interviewers ask about all do. They are chosen so that one of four moves cracks them. Recognising which one is most of the skill.


When an interviewer writes an SDE on the board and says "solve it", they rarely mean "find the solution as a function of the Brownian path". Sometimes they do, for geometric Brownian motion or the Ornstein–Uhlenbeck process. More often they want a number: the mean at time one, the probability of hitting a barrier first, the variance in the long run. Each of those has a shortcut that avoids solving anything, and taking the long way round is the most common way candidates run out of time.

Move 1: apply Itô's lemma to the right function

For multiplicative noise, look for a function that turns the equation into one with constant coefficients. Geometric Brownian motion, dS = μS dt + σS dW, is the standard case. The logarithm removes the S on the right:

d(ln S) = dS/S − ½ (dS)²/S² = (μ − ½σ²) dt + σ dW

Integrate both sides and St = S0 exp((μ − ½σ²)t + σWt). The −½σ² comes from the (dS)² term, which ordinary calculus would drop and Itô calculus cannot, because (dW)² = dt. It is the single most important correction in the subject, and the one interviewers listen for.

It has a consequence worth knowing in numbers. Take S0 = 100, μ = 6% and σ = 25% over one year. The mean is 100e0.06 ≈ 106.2, but the median is 100e0.06 − 0.03125 ≈ 102.9. Half of all paths end below 102.9. The difference is volatility drag, and it is why the growth rate of wealth is μ − ½σ², not μ.

Move 2: an integrating factor, for linear equations with additive noise

The Ornstein–Uhlenbeck process, dX = −θX dt + σ dW, pulls X back towards zero. It is linear in X and the noise does not depend on X, which is the signal to use the same trick as for a linear ODE. Multiply by eθt:

d(eθtX) = θeθtX dt + eθt dX = σeθt dW

The drift cancels, so Xt = e−θtX0 + σ∫0t e−θ(t−s) dWs. The integral of a deterministic function against dW is normal, with variance given by the Itô isometry, so Xt is normal with mean e−θtX0 and variance σ²(1 − e−2θt)/(2θ). As t grows the variance settles at σ²/(2θ).

With θ = 2 and σ = 0.4 the long-run standard deviation is 0.2, and a deviation halves in ln 2/θ ≈ 0.35 time units. That half-life is what a pairs trader estimates first, because it says how long a position on a mean-reverting spread should take to work.

Move 3: when you only need moments, don't solve at all

Take expectations of both sides. The dW term has mean zero whatever multiplies it, so the mean obeys an ordinary differential equation, and the noise disappears from it entirely. For the second moment, apply Itô to X² first and then take expectations.

The CIR model for interest rates, dr = κ(θ − r) dt + σ√r dW, has no Gaussian solution, and you do not need one. With κ = 1.5, θ = 3%, σ = 0.15 and r0 = 5%, the mean solves m′ = κ(θ − m), so E[r1] = 0.03 + 0.02e−1.5 ≈ 3.45%. Itô on r² gives the stationary variance θσ²/(2κ) = 0.000225, a standard deviation of 1.5 percentage points. And because 2κθ = 0.09 exceeds σ² = 0.0225 (the Feller condition), the rate never touches zero.

The same move answers a question that looks harder than it is. For dX = (aX + b) dt + σX dW the volatility does not appear in the mean at all: m′ = am + b, whatever σ is. Candidates who start solving the SDE lose five minutes finding that out.

Move 4: for hitting probabilities, find the scale function

"Which barrier does X reach first?" is answered by a function s with s(Xt) a martingale. For dX = μ dt + σ dW that means ½σ²s″ + μs′ = 0, so s(x) = e−2μx/σ². Optional stopping then gives the probability of reaching b before a, starting from x:

P = (s(a) − s(x)) / (s(a) − s(b))

With μ = 1, σ = 2, starting at 0, the probability of reaching +2 before −1 is (e0.5 − 1)/(e0.5 − e−1) ≈ 0.506. The upper barrier is twice as far, and the drift almost exactly makes up for it. The expected time to leave the interval follows from a second martingale, Xt − μt: E[XT] = μE[T], which gives about 0.52.

Let the far barrier go to infinity and the same formula says a process drifting upwards ever falls by a with probability e−2μa/σ². The largest drawdown of a drifting Brownian motion is exponentially distributed, which is a useful thing to have in your head in a risk interview.

When none of them works: simulate, carefully

For anything else, Euler–Maruyama is the default: X + μ(X)Δt + σ(X)ΔW, step by step. Its pathwise error shrinks only like √Δt. The Milstein scheme adds ½σσ′((ΔW)² − Δt) and gets order Δt. When the transition is known exactly, as for geometric Brownian motion and the Ornstein–Uhlenbeck process, step with that instead and the discretisation error is zero.

Hitting times need more care than moments. When we checked the exit-time question in our SDE question bank by simulation, a step of 0.001 gave an expected exit time of 0.96 against an exact 0.924. The simulation was not noisy, it was biased: checking the barrier only at grid points misses crossings that happen between them, so every path appears to leave late. Halving the error means cutting the step by a factor of four. If an interviewer asks how you would price a barrier option by Monte Carlo, this is the problem they want you to raise, and the fix is a Brownian-bridge correction for the chance of a crossing between steps.

Which move, at a glance

The question looks likeUseExample
dS = μS dt + σS dW, solve itItô on ln SS0e(μ − σ²/2)t + σW
Linear drift, additive noiseIntegrating factor eθtOrnstein–Uhlenbeck, Vasicek
"What is E[Xt]" or a varianceMoment equationsCIR, any linear SDE
Which barrier first, or how longScale function, optional stoppingGambler's ruin with drift
An expectation of a payoffFeynman–Kac: write the PDEBlack–Scholes
None of the aboveSimulate, with the exact step if there is oneBarrier and path-dependent payoffs

Fifty questions that drill exactly these moves, each with a full solution and checked by simulation, are in the stochastic differential equations bank. The Brownian-motion groundwork behind them, Itô's lemma, martingales and Girsanov, is in the stochastic calculus bank.

Questions people ask

Can every stochastic differential equation be solved in closed form?

No. Closed forms exist for linear equations, such as geometric Brownian motion, the Ornstein–Uhlenbeck process and the Brownian bridge, and for equations that a change of variable reduces to one of these. Most others, including CIR, have explicit transition densities or moments but no formula in terms of the Brownian path, and many have neither. That is why the moment and martingale methods above matter more in practice than the solutions themselves.

What is the difference between the Itô and Stratonovich forms?

They are two conventions for the integral against dW. Itô evaluates the integrand at the start of each interval, which makes stochastic integrals martingales and suits finance, where you cannot trade on information you do not have yet. Stratonovich uses the midpoint, which makes the ordinary chain rule hold. dX = σX ∘ dW in Stratonovich form is dX = ½σ²X dt + σX dW in Itô form.

What makes a solution "strong" rather than "weak"?

A strong solution is built from a given Brownian motion, path by path. A weak solution only needs some probability space and some Brownian motion on which the equation holds, so it pins down the distribution but not the path. Lipschitz coefficients guarantee a unique strong solution; Tanaka's equation dX = sign(X) dW has a weak solution and no strong one.

How do I check an answer in an interview?

Three checks catch most mistakes. Set the noise to zero and see whether the answer reduces to the ODE solution. Check a limit: as t grows, a mean-reverting process should forget where it started. And check units: a variance should scale with σ², a time with 1/μ or 1/σ².

PDF · Edition 2 · £79

The Quant Careers Report

Stochastic calculus is one round of several. The report covers how 13 trading firms interview, the pay they state, and when each programme takes applications.

Buy the report — £79 See what is inside


Read next

LinkedIn X Facebook WhatsApp Telegram Email