Coupled Stochastic Differential Equations

Coupled SDEs model systems where multiple stochastic processes interact. Asgard supports multi-equation stochastic systems with correlated noise, expression-based drift and diffusion, and post-simulation analysis.

Overview

A coupled SDE system has the form:

dX₁ = f₁(X₁, X₂, ..., t) dt + g₁(X₁, X₂, ..., t) dW₁
dX₂ = f₂(X₁, X₂, ..., t) dt + g₂(X₁, X₂, ..., t) dW₂
...

where the noise terms dW₁, dW₂, ... can be correlated.

YAML Format

Coupled SDEs use the equations list instead of a single equation field:

name: Mass-Spring-Damper
description: |
  Position and velocity coupled through Newton's second law,
  with stochastic forcing on the velocity.

stochastic:
  calculus: ito
  n_paths: 500
  dt: 0.01
  seed: 42

simulate:
  t_start: 0.0
  t_end: 10.0

coupled:
  correlation: 0.0       # Independent noise sources

equations:
  - name: X
    description: "Position"
    drift_expr: "x[:, 1]"
    diffusion_expr: "0.0 * ones_like(x[:, 0])"
    x0: 1.0

  - name: V
    description: "Velocity"
    drift_expr: "-k * x[:, 0] - c * x[:, 1]"
    diffusion_expr: "sigma * ones_like(x[:, 1])"
    x0: 0.0

params:
  k: 4.0       # Spring constant
  c: 0.5       # Damping coefficient
  sigma: 0.3   # Noise intensity

output:
  type: StochasticEnsemble
  title: "Mass-Spring-Damper System"

Expression Syntax

Drift and diffusion are defined as Python expressions with access to:

The state array x has shape (n_paths, n_equations), so x[:, 0] is the first variable (e.g., position) and x[:, 1] is the second (e.g., velocity).

Correlated Noise

The coupled.correlation field controls noise correlation between equations:

Independent noise (default):

coupled:
  correlation: 0.0

Scalar correlation (same correlation between all pairs):

coupled:
  correlation: -0.7     # e.g., price-volatility anti-correlation

Correlation matrix (full control):

coupled:
  correlation:
    - [1.0, -0.7]
    - [-0.7, 1.0]

Internally, correlated Brownian increments are generated using Cholesky decomposition of the correlation matrix.

Example: Heston Stochastic Volatility

The Heston model couples asset price S with variance v:

dS = mu * S dt + sqrt(v) * S dW₁
dv = kappa * (theta - v) dt + sigma_v * sqrt(v) dW₂

with correlation rho between dW₁ and dW₂.

name: Heston Stochastic Volatility
description: |
  Coupled price-volatility model with mean-reverting variance.
  The negative correlation between price and volatility produces
  the leverage effect seen in equity markets.

stochastic:
  calculus: stratonovich
  n_paths: 2000
  dt: 0.005
  seed: 42

simulate:
  t_start: 0.0
  t_end: 1.0

coupled:
  correlation: -0.7      # Price-volatility anti-correlation

equations:
  - name: S
    description: "Asset price"
    equation: "dS = mu * S dt + sqrt(v) * S dW"
    drift_expr: "mu * x[:, 0]"
    diffusion_expr: "sqrt(abs(x[:, 1])) * x[:, 0]"
    x0: 100.0

  - name: v
    description: "Variance"
    equation: "dv = kappa * (theta - v) dt + sigma_v * sqrt(v) dW"
    drift_expr: "kappa * (theta - x[:, 1])"
    diffusion_expr: "sigma_v * sqrt(abs(x[:, 1]))"
    x0: 0.04

params:
  mu: 0.05
  kappa: 2.0
  theta: 0.04
  sigma_v: 0.3

output:
  type: StochasticEnsemble
  title: "Heston Model: Stochastic Volatility"

Analysis Features

Add post-simulation analysis to coupled SDE examples:

Percentile Bands

analysis:
  percentiles: [5, 25, 50, 75, 95]

Computes path percentiles at each time step, useful for confidence bands and risk metrics.

First-Passage Time

analysis:
  first_passage_time:
    threshold: 1.5

Computes the distribution of times when paths first cross the threshold. Useful for reliability analysis, barrier option pricing, and maintenance scheduling.

Tips

Next Steps