Itō Calculus and Stochastic Differential Equations

by Manuel de Prada Corral

2 min read

Basic notes of Itō calculus applied to stochastic differential equations (SDEs), with code to simulate and filter stochastic processes.

Intro

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

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.

TODOs

  • Sequential Monte Carlo
  • Geometric Brownian motion
  • Stochastic differential equations definition
  • full demo
  • Applications in finance