Stochastic Processes & SDE Lab
Interactive simulation and numerical analysis of stochastic differential equations used in quantitative finance. Explore Brownian motion, geometric Brownian motion, mean-reverting processes, short-rate models, and stochastic volatility while comparing simulated distributions, theoretical moments, and numerical discretization error.
Running production Monte Carlo simulation…
Airo React → Railway FastAPI → NumPy vectorized simulation
Model Equation
Ornstein–Uhlenbeck
dX_t = κ(θ − X_t) dt + σ dW_t
X₀ = initial value · κ = mean-reversion speed · θ = long-run mean · σ = volatility
Gaussian mean-reverting process useful for spreads, signals, factors, and simplified market dynamics.
Empirical Mean
Theoretical Mean
Model Diagnostic
Backend Runtime
Simulated Sample Paths
Production Python/NumPy Monte Carlo paths
Terminal Distribution
Backend terminal sample with analytical density overlay where implemented
Mean & Variance Through Time
Empirical backend moments vs analytical trajectories where available
Numerical Convergence
Independent client-side GBM validation using shared Brownian paths: Euler–Maruyama vs Milstein vs exact solution
Theoretical vs Empirical Moments
| Statistic | Theoretical | Simulation | Absolute Error |
|---|---|---|---|
| E[X_T] | — | — | — |
| Var[X_T] | — | — | — |
| Std Dev | — | — | — |
Process Diagnostics
Model
Ornstein–Uhlenbeck
Monte Carlo Paths
10,000
Δt
—
Backend Runtime
—
Model Validation Summary
Connecting to the production stochastic engine…
METHODOLOGY & IMPLEMENTATION
Model Workflow
Stochastic Differential Equations
Each process is defined by a drift term and diffusion term driven by Brownian motion. The page exposes the economically important parameters and lets the user observe how they change path behavior and terminal distributions.
Production Monte Carlo Simulation
Scenario parameters are sent to a FastAPI endpoint on Railway. NumPy vectorizes thousands of simulated paths and returns sample paths, terminal observations, empirical mean and variance through time, model diagnostics, and request-side runtime.
Analytical Moment Validation
For Brownian motion, GBM, Ornstein–Uhlenbeck, Vasicek, and CIR, known analytical moments are compared with Monte Carlo estimates. The UI reports absolute moment errors rather than relying only on visual path inspection.
Mean Reversion & Rate Models
OU, Vasicek, and CIR expose mean-reversion speed and long-run level. The mean-reversion half-life ln(2)/κ is reported directly, while CIR also evaluates the Feller condition 2κθ ≥ σ².
Heston Stochastic Volatility
The Heston simulation evolves spot and variance jointly with correlated Gaussian shocks. Full-truncation style safeguards keep simulated variance non-negative in the numerical scheme.
Numerical Convergence
A separate reproducible GBM experiment compares Euler–Maruyama and Milstein terminal strong error against the exact GBM solution using shared Brownian paths. The measured log-log slopes provide a numerical convergence diagnostic.
Numerical Methods
Technologies
Plain-English Interpretation
The objective is not merely to draw stochastic paths. The lab connects continuous-time model equations to numerical simulation, checks Monte Carlo output against known theory where available, exposes discretization and model diagnostics, and measures the accuracy-versus-computation trade-off that appears in pricing and risk systems.