Understanding Itō Calculus and Its Application in Stochastic Differential Equations

by Manuel de Prada Corral

3 min read

In this blog post, we will explore the essential concepts of Itō calculus and how they apply to solving stochastic differential equations (SDEs). We will also see how these concepts are implemented in Python code to simulate and filter stochastic processes.

What is Itō Calculus?

Itō calculus extends classical calculus to stochastic processes, particularly those driven by Brownian motion. It includes key tools like the Itō integral and Itō's Lemma.

Brownian Motion

Brownian motion Bt B_t is a continuous-time stochastic process with:

  1. B0=0 B_0 = 0 .
  2. Independent increments.
  3. Normally distributed increments: Bt+sBtN(0,s) B_{t+s} - B_t \sim \mathcal{N}(0, s) .

Itō Integral

The Itō integral of a process Xt X_t with respect to Brownian motion Bt B_t is denoted: 0tXs,dBs \int_0^t X_s , dB_s

Itō's Lemma

Itō's Lemma is the stochastic counterpart of the chain rule. For a function f(t,Xt) f(t, X_t) where Xt X_t follows: dXt=μ(t,Xt),dt+σ(t,Xt),dBt, dX_t = \mu(t, X_t) , dt + \sigma(t, X_t) , dB_t, Itō's Lemma states: df(t,Xt)=(ft+μfX+12σ22fX2)dt+σfX,dBt. df(t, X_t) = \left( \frac{\partial f}{\partial t} + \mu \frac{\partial f}{\partial X} + \frac{1}{2} \sigma^2 \frac{\partial^2 f}{\partial X^2} \right) dt + \sigma \frac{\partial f}{\partial X} , dB_t.

Solving SDEs with Itō's Lemma

Consider the SDE: dXt=μXt,dt+σXt,dBt dX_t = \mu X_t , dt + \sigma X_t , dB_t

Applying Itō's Lemma to Yt=ln(Xt) Y_t = \ln(X_t) : dYt=(μ12σ2)dt+σ,dBt dY_t = \left( \mu - \frac{1}{2} \sigma^2 \right) dt + \sigma , dB_t

Solving this: Yt=ln(Xt)=ln(X0)+(μ12σ2)t+σBt Y_t = \ln(X_t) = \ln(X_0) + \left( \mu - \frac{1}{2} \sigma^2 \right) t + \sigma B_t

Exponentiating both sides: Xt=X0exp((μ12σ2)t+σBt) X_t = X_0 \exp \left( \left( \mu - \frac{1}{2} \sigma^2 \right) t + \sigma B_t \right)

Implementation in Python

Here's how this is implemented in the context of a particle filter simulation:

import numpy as np

# Parameters
y0 = 1.0
mu = 0.1
sigma = 0.2
T = 1.0
N = 100
M = 1000
dt = T / N

# Placeholder for observations and time
time = np.linspace(0, T, N+1)
true_state = np.exp((mu - 0.5 * sigma**2) * time + sigma * np.random.normal(0, np.sqrt(time)))

# Simulate and plot the true state
import matplotlib.pyplot as plt

plt.figure(figsize=(10, 6))
plt.plot(time, true_state, label='True State')
plt.xlabel('Time')
plt.ylabel('State')
plt.title('True State Evolution Using Itō Calculus')
plt.legend()
plt.show()

In the code:

  • true_state is calculated using the derived formula from Itō's Lemma.
  • np.random.normal(0, np.sqrt(time)) simulates the Brownian motion increments. This demonstrates how Itō calculus is applied to model and simulate stochastic processes, providing a powerful toolset for understanding systems influenced by randomness.

Missing:

  • Sequential Monte Carlo
  • Geometric Brownian motion
  • Stochastic differential equations definition
  • full demo
  • Applications in finance
Batch Size A100 80G Batch/s A100 80G Tok/s 1xA100 40G Batch/s 1xA100 40G Tok/s 2xA100 40G Batch/s 2xA100 40G Tok/s 3xA100 40G Batch/s 3xA100 40G Tok/s 4xA100 40G Batch/s 4xA100 40G Tok/s
1 47.46 47.46 37.51 37.51 29.56 29.56 29.44 29.44 28.35 28.35
4 49.76 199.04 38.81 155.24 30.15 120.6 28.14 112.56 28.83 115.32
8 49.12 393.0 41.64 333.12 30.38 243.04 28.23 225.84 28.88 231.04
16 49.35 789.6 39.85 637.6 28.92 462.72 26.33 421.28 26.76 428.16
32 47.75 1528.0 37.64 1204.48 27.71 886.72 27.87 892.84 27.98 895.36
64 39.55 2531.2 33.44 2140.16 27.97 1790.08 22.35 1430.4 22.4 1433.6
128 25.86 3310.1 22.13 2832.64 22.48 2877.44 15.77 2018.56 15.67 2005.76
256 15.32 3921.9 12.61 3227.36 14.15 3622.4 9.53 2439.68 8.77 2245.12
512 8.17 4183.0 OOM OOM 7.4 3788.8 6.88 3522.56 4.83 2472.96
750 OOM OOM OOM OOM 5.07 3802.5 3.73 2797.5
1024 OOM OOM 3.03 3102.72
1500 OOM OOM