dS = μS·dt + σS·dW · step-by-step Wiener integration · empirical vs theoretical lognormal statistics
Watch dS = μS·dt + σS·dW get integrated step by step with the Euler-Maruyama scheme — a genuine numerical solver for a stochastic differential equation, not the closed-form shortcut. Every path draws its own independent sequence of Wiener increments, and the panel tracks how the empirical mean and variance across all simulated paths converge to the exact lognormal formulas as more steps are taken.
Rather than jumping straight to the closed-form solution S(t) = S₀·exp((μ−σ²/2)t + σ√t·Z), this simulator walks the SDE forward one discrete step at a time: S(t+dt) = S(t) + μS(t)dt + σS(t)ΔW, with ΔW = Z√dt drawn fresh from a standard normal for every path at every step (Euler-Maruyama). Because it is a first-order approximation, the discretisation error shrinks as dt shrinks — raise the "steps/year" slider and watch the empirical mean/variance error drop toward the exact lognormal values shown alongside it.
Set μ and σ to explore bull/bear/volatile regimes, and N to control how many independent paths feed the statistics (more paths = tighter empirical convergence). The "Empirical vs Theoretical" panel reports the sample mean and variance of final prices against S₀e^(μT) and the exact lognormal variance formula, plus their relative error live. The histogram below overlays the empirical final-price density (bars) against the exact lognormal probability density (yellow curve) for the current elapsed time.
Euler-Maruyama is the stochastic analogue of Euler's method for ordinary differential equations, but it only converges at order √dt in the strong sense — much slower than its deterministic counterpart — which is exactly why quants use the exact GBM solution when they can, and finer schemes like Milstein when they can't. This simulator intentionally keeps the simple first-order scheme visible so the convergence behaviour itself is the thing on display.
This 2D companion simulator numerically integrates the geometric Brownian motion stochastic differential equation dS = μS·dt + σS·dW with the Euler-Maruyama scheme, generating a fresh standard-normal Wiener increment for every path at every discrete time step rather than jumping to the closed-form lognormal solution. It exists to make the numerical-integration process itself visible, and to show live how the empirical statistics of many simulated paths converge to the exact theoretical formulas as the step count increases.
Each path is built by repeatedly applying S(t+dt) = S(t) + μS(t)dt + σS(t)ΔW with ΔW = Z·√dt, Z drawn fresh (Box-Muller) at every step. The theoretical mean E[S(t)] = S₀e^(μt) and variance Var[S(t)] = S₀²e^(2μt)(e^(σ²t)−1) are computed exactly and compared live against the sample mean and variance across all N simulated paths, including the relative error between them.
Six controls: drift μ, volatility σ, number of paths N, time horizon T, and steps-per-year (the dt resolution of the Euler-Maruyama scheme). Raising steps-per-year shrinks dt and reduces discretisation error — watch the "mean rel. error" figure fall. Raising N tightens the empirical histogram around the true lognormal density (yellow curve). Press "Run New Simulation" for a fresh random ensemble.
Euler-Maruyama is the direct stochastic generalisation of Euler's method for ODEs, but its strong convergence order is only 0.5 in dt (versus 1.0 for the deterministic Euler method) — a consequence of the √dt scaling of Brownian increments. That is why numerical analysts reach for the higher-order Milstein scheme when precision matters, even though Euler-Maruyama remains the simplest correct way to simulate an SDE from first principles.
Euler-Maruyama is a numerical scheme for integrating stochastic differential equations. It advances a random process one small time step dt at a time using S(t+dt) = S(t) + μS(t)dt + σS(t)ΔW, where ΔW = Z√dt is a genuine random Wiener increment drawn from a standard normal distribution at every step. It is the simplest way to simulate an SDE without relying on a closed-form solution.
The 3D companion computes each path directly from the exact closed-form GBM solution S(t) = S₀·exp((μ−σ²/2)t + σ√t·Z). This 2D simulator instead walks the stochastic differential equation forward step by step with Euler-Maruyama, so you can see the numerical integration process itself and how its accuracy depends on the step size (dt).
Two independent sources of error are visible: Monte Carlo sampling error, which shrinks as you increase the number of paths N, and Euler-Maruyama discretisation error, which shrinks as you increase steps-per-year (making dt smaller). Watching the "mean rel. error" figure fall as you raise either slider demonstrates both effects directly.
It is the exact lognormal probability density function of S(t) at the current elapsed time, computed analytically from μ, σ and t. The green/red bars are the empirical density estimated from the simulated final prices across all paths. As N grows and dt shrinks, the bars should hug the yellow curve increasingly closely.
Geometric Brownian motion has multiplicative noise (σS·dW rather than plain σ·dW), so the size of each random shock scales with the current price — as price approaches zero its fluctuations shrink too, which keeps the true process strictly positive. The Euler-Maruyama scheme can occasionally overshoot below zero for a large discrete step; this simulator clamps that rare case to a tiny positive value so the log-price stays defined.