Table of Contents
Fetching ...

Differentiating through Stochastic Differential Equations: A Primer

Rishi Leburu, Levon Nurbekyan, Lars Ruthotto

TL;DR

This work provides a structured primer on differentiating through stochastic differential equations to compute gradients of expectations with respect to initial conditions and parameters. It presents two complementary narratives: discretize-then-optimize (applicable to Itô and Stratonovich SDEs) and optimize-then-discretize (via continuous adjoints, with Stratonovich as the natural setting), and demonstrates when each approach yields correct limits. Through Black–Scholes and CEV examples, it shows that discretize-then-optimize yields exact gradients for the discretized problem, while optimize-then-discretize converges to the continuous Stratonovich adjoint (requiring drift corrections for Itô) and can be practically implemented with Stratonovich schemes such as Heun. The paper offers practical guidelines, connects to rough-path theory, and outlines applications across finance, machine learning, and optimal control, with public code to reproduce results.

Abstract

Dynamical systems are essential to model various phenomena in physics, finance, economics, and are also of current interest in machine learning. A central modeling task is investigating parameter sensitivity, whether tuning atmospheric coefficients, computing financial Greeks, or optimizing neural networks. These sensitivities are mathematically expressed as derivatives of an objective function with respect to parameters of interest and are rarely available analytically, necessitating numerical methods for approximating them. While the literature for differentiation of deterministic systems is well-covered, the treatment of stochastic systems, such as stochastic differential equations (SDEs), in most curricula is less comprehensive than the subtleties arising from the interplay of noise and discretization require. This paper provides a primer on numerical differentiation of SDEs organized as a two-tale narrative. Tale 1 demonstrates differentiating through discretized SDEs, known the discretize-optimize approach, is reliable for both Itô and Stratonovich calculus. Tale 2 examines the optimize-discretize approach, investigating the continuous limit of backward equations from Tale 1 corresponding to the desired gradients. Our aim is to equip readers with a clear guide on the numerical differentiation of SDEs: computing gradients correctly in both Itô and Stratonovich settings, understanding when discretize-optimize and optimize-discretize agree or diverge, and developing intuition for reasoning about stochastic differentiation beyond the cases explicitly covered.

Differentiating through Stochastic Differential Equations: A Primer

TL;DR

This work provides a structured primer on differentiating through stochastic differential equations to compute gradients of expectations with respect to initial conditions and parameters. It presents two complementary narratives: discretize-then-optimize (applicable to Itô and Stratonovich SDEs) and optimize-then-discretize (via continuous adjoints, with Stratonovich as the natural setting), and demonstrates when each approach yields correct limits. Through Black–Scholes and CEV examples, it shows that discretize-then-optimize yields exact gradients for the discretized problem, while optimize-then-discretize converges to the continuous Stratonovich adjoint (requiring drift corrections for Itô) and can be practically implemented with Stratonovich schemes such as Heun. The paper offers practical guidelines, connects to rough-path theory, and outlines applications across finance, machine learning, and optimal control, with public code to reproduce results.

Abstract

Dynamical systems are essential to model various phenomena in physics, finance, economics, and are also of current interest in machine learning. A central modeling task is investigating parameter sensitivity, whether tuning atmospheric coefficients, computing financial Greeks, or optimizing neural networks. These sensitivities are mathematically expressed as derivatives of an objective function with respect to parameters of interest and are rarely available analytically, necessitating numerical methods for approximating them. While the literature for differentiation of deterministic systems is well-covered, the treatment of stochastic systems, such as stochastic differential equations (SDEs), in most curricula is less comprehensive than the subtleties arising from the interplay of noise and discretization require. This paper provides a primer on numerical differentiation of SDEs organized as a two-tale narrative. Tale 1 demonstrates differentiating through discretized SDEs, known the discretize-optimize approach, is reliable for both Itô and Stratonovich calculus. Tale 2 examines the optimize-discretize approach, investigating the continuous limit of backward equations from Tale 1 corresponding to the desired gradients. Our aim is to equip readers with a clear guide on the numerical differentiation of SDEs: computing gradients correctly in both Itô and Stratonovich settings, understanding when discretize-optimize and optimize-discretize agree or diverge, and developing intuition for reasoning about stochastic differentiation beyond the cases explicitly covered.
Paper Structure (20 sections, 70 equations, 3 figures, 1 table)

This paper contains 20 sections, 70 equations, 3 figures, 1 table.

Figures (3)

  • Figure 1: Error in discrete adjoint gradient compared to the analytical $\Delta$ versus time step size $\Delta t$ for Black--Scholes model on log-log scale. Computations using $n = 10^5$ Monte Carlo paths with parameters $S_0 = 100$, $K = 110$, $r = 0.05$, $\sigma = 0.2$, $T = 1$.
  • Figure 1: Histograms of pathwise gradients $\Delta = \partial C / \partial S_0$ for the CEV model with $\beta = 1.33$, comparing discrete-adjoint and naive-adjoint estimators. The x-axis is restricted to the pooled $[ 0.1\%, 98\% ]$ quantile range and the "Zoomed Window" note reports the per-method share of samples that fall beyond the right bound (Discrete $1.08\%$, Naive $2.92\%$). Computations using 5,000 Monte Carlo paths with $\Delta t = 0.01$.
  • Figure 2: Histograms of pathwise gradients $\Delta = \partial C / \partial S_0$ for the CEV model with $\beta = 1.33$, comparing Itô discrete adjoint (Euler-Maruyama) versus corrected Stratonovich adjoint (Heun). The x-axis is restricted to the pooled $[0.1\%, 98\%]$ quantile range, and the "Zoomed Window" note reports the per-method share of samples that fall beyond the right bound (Itô $1.98\%$, Corrected $2.00\%$). Computations using 5,000 Monte Carlo paths with $\Delta t = 10^{-3}$.