Part 1 - An Introduction to Stochastic Processes

Introduction

Most SDEs take the form,

dx(t)=f(x(t),t) dtdrift+L(x(t),t) dβ(t)diffusion,\begin{equation} dx(t) = \underbrace{f(x(t), t) \ dt}_{\text{drift}} + \underbrace{L(x(t), t) \ d\beta(t)}_{\text{diffusion}}, \end{equation}

where x(t)x(t) is a stochastic process and β(t)\beta(t) is Brownian motion 1.

The SDE in Equation (1) is shorthand for the (Itô, teaser!) integral equation,

x(t)x(t0)=t0tf(x(s),s) ds+t0tL(x(s),s) dβ(s).x(t) - x(t_0) = \int_{t_0}^{t} f(x(s), s) \ ds + \int_{t_0}^{t} L(x(s), s) \ d\beta(s).
SDE with only drift (an ODE)
SDE with only drift (an ODE)

Suppose f(x,t)=2,L(x,t)=0f(x, t) = 2, L(x, t) = 0, dxdt=2\Rightarrow \frac{dx}{dt} = 2.

We also assume that x(0)N(0,2)x(0) \sim \mathcal{N}(0, 2). See Figure 1.

Definition 1 (Definition: Brownian motion –   β(t)\beta(t))
  1. Any increment Δβ=β(t)β(t)N(0,(tt)Q).\Delta \beta = \beta(t^{\prime}) - \beta(t) \sim \mathcal{N}(0, (t^{\prime} - t) Q). (Often Q=1Q = 1).
  2. Increments are independent unless intervals overlap.
  3. β(0)=0\beta(0) = 0.
SDE with only diffusion.
SDE with only diffusion.

Suppose f(x,t)=0,L(x,t)=2f(x, t) = 0, L(x, t) = 2, dx(t)=2 dβ(t)\Rightarrow dx(t) = 2 \ d \beta(t).

We also assume that x(0)N(0,1)x(0) \sim \mathcal{N}(0, 1). See Figure 2.

To sample x(t)x(t), we can draw x(0)p(x(0))x(0) \sim p(x(0)) and then repeat,

x(t+Δt)=x(t)+f(x(t),t)Δt+L(x(t),t)z,zN(0,Δt).\begin{equation} x(t + \Delta t) = x(t) + f(x(t), t) \Delta t + L(x(t), t)z, \quad z \sim \mathcal{N}(0, \Delta t). \end{equation}
Sample of a SDE.
Sample of a SDE.

We can use Equation (2) to sample from,

dx(t)=0.5x dt+dβ(t),d x(t) = 0.5x \ dt + d \beta(t),

which corresponds to f(x,t)=0.5xf(x, t) = 0.5x and L(x,t)=1L(x, t) = 1. See Figure 3.

Motivation and Dynamic Models

SDEs are commonly used to model object dynamics (cars, airplanes, etc).

Often, time-discretized versions are used for filtering, smoothing, and prediction.

Constant Velocity Models (Scalar Example)

Suppose x(t)=[x(t)v(t)]T\mathbf{x}(t) = \begin{bmatrix} x(t) & v(t) \end{bmatrix}^T represents the position and velocity of an object.

According to the constant velocity model,

dx(t)=[0100]x(t) dt+[0q]dβ(t),=[v(t) dt0]+[0q dβ(t)].\begin{align*} d \mathbf{x}(t) & = \begin{bmatrix} 0 & 1 \newline 0 & 0 \end{bmatrix} \mathbf{x}(t) \ dt + \begin{bmatrix} 0 \newline q \end{bmatrix} d \beta(t), \newline \Leftrightarrow & = \begin{bmatrix} v(t) \ dt \newline 0 \end{bmatrix} + \begin{bmatrix} 0 \newline q \ d \beta(t) \end{bmatrix}. \end{align*}

The position follows the velocity, whereas the velocity is a Brownian motion.

Constant Velocity Model with .
Constant Velocity Model with .

The Ornstein-Uhlenbeck process 2,

dv(t)=θv(t) dt+σ dβ(t),dv(t) = -\theta v(t) \ dt + \sigma \ d \beta(t),

is used in several fields, e.g., in physics to model particles moving with friction.

The Black-Scholes equation 3 is widely used in finacne to model the value of “financial instruments”.

A basic version of this equation is,

d s(t)=μs(t) dt+σs(t) dβ(t),d \ s(t) = \mu s(t) \ dt + \sigma s(t) \ d \beta(t),

where s(t)s(t) is the stock price.

The stochastic Lotka-Volterra 4 model describes the predator-prey dynamics,

dx(t)=x(t)(aby(t)) dt+σ1x(t) dβ1(t),dy(t)=y(t)(c+dx(t)) dt+σ2y(t) dβ2(t).\begin{align*} dx(t) & = x(t)(a - b y(t)) \ dt + \sigma_1 x(t) \ d \beta_1(t), \newline dy(t) & = y(t)(-c + d x(t)) \ dt + \sigma_2 y(t) \ d \beta_2(t). \end{align*}

Here, x(t)x(t) and y(t)y(t) are the prey and the predator populations, respectively, and β1(t)\beta_1(t) and β2(t)\beta_2(t) are independent Brownian motions.

Diffusion can be used as a (deep) generative model as well (and this is what we are mostly interested in).

The forward and backward processes of the diffusion model.
The forward and backward processes of the diffusion model.

The basic idea is,

  • Recursively remove structure from data (make it noisier!).
  • Train network to remove noise and obtain structure again.
  • Generate (new) data by feeding noise to the trained network.

The forward process is generally an SDE,

dx(t)=f(x,t) dt+L(t) dβ(t).d x(t) = f(x, t) \ dt + L(t) \ d \beta(t).

We are going to get a solid understanding of theoretical results used to train and perform inference in these models.

Image generation is arguably the most well-known application. A few other examples are,

  • Besides bridging noise and data distributions we can bridge, e.g., low- and high-resolution images.
  • Molecular and drug design, e.g., protein structures.
  • Sequential data, e.g., human pose sequences and financial data.
  • Motion planning and reinforcement learning with diffusion policies.

The Engineering Approach: White Noise

Recall that we study SDEs on the form,

dx(t)=f(x(t),t) dt+L(x(t),t) dβ(t),x(t)x(t0)=t0tf(x(s),s) ds+t0tL(x(s),s) dβ(s).\begin{align*} dx(t) & = f(x(t), t) \ dt + L(x(t), t) \ d \beta(t), \newline x(t) - x(t_0) & = \int_{t_0}^t f(x(s), s) \ ds + \int_{t_0}^t L(x(s), s) \ d \beta(s). \end{align*}

In engineering literature, the notation dβ(t)d \beta(t) is uncommon in integrals.

Imagine for a second that if β(t)\beta(t) were differentiable (it isn’t!), we could introduce w(t)=dβ(t)dtw(t) = \frac{d \beta(t)}{dt},

dx(t)dt=f(x,t)+L(x,t) w(t),x(t1)x(t0)=t0t1f(x(s),s) ds+t0t1L(x(s),s)w(s) ds,\begin{align*} \frac{dx(t)}{dt} & = f(x, t) + L(x, t) \ w(t), \newline x(t_1) - x(t_0) & = \int_{t_0}^{t_1} f(x(s), s) \ ds + \int_{t_0}^{t_1} L(x(s), s) w(s) \ ds, \end{align*}

where w(t)w(t) is white noise.

In engineering literature, this is the standard form to express SDEs.

However, what is white noise? We know that β(t)\beta(t) has independent increments.

It is common to assume that w(t)w(t) is a Gaussian process with,

E[w(t)]=0,Cov(w(t),w(t+τ))=δ(τ).\begin{align*} \mathbb{E}[w(t)] & = 0, \newline \mathrm{Cov}(w(t), w(t + \tau)) & = \delta(\tau). \end{align*}

However, if we naively use these assumptions to derive, e.g., E[X(t)]\mathbb{E}[X(t)] and Cov(x(t))\mathrm{Cov}(x(t)), we get the wrong expression for Cov(x(t))\mathrm{Cov}(x(t)).

“The white Gaussian process is mathematical fiction”. - AH Jazwinski.

We’ll take the (more) mathematical approach and express SDEs using dβ(t)d \beta(t) and learn about Itô calculus 5 to enable us to derive the correct expressions.

Basic Results on Random Variables

Formally, we can introduce a probability space with,

  • A probability (or sample) space Ω\Omega, whose elements ωΩ\omega \in \Omega are called sample points,
  • A σ\sigma-algebra F\mathcal{F} 6, and,
  • A probability measure 7 Pr(F)Pr(F) for FFF \in \mathcal{F}.

A random variable is then a function x(ω)x(\omega).

We’ll occasionally use the notation x(ω)x(\omega), but generally characterize random variables using,

  • Pr[x]Pr[x], a probability mass function, for discrete random variables,
  • p(x)p(x), a probability density function, for continuous random variables.

Some (very) basic concepts from probability theory,

  • Expected values: E[f(x)]\mathbb{E}[f(x)] = f(x)p(x) dx\int f(x) p(x) \ dx,
  • Variance: Var(x)=E[(xE[x])2]\mathrm{Var}(x) = \mathbb{E}[(x - \mathbb{E}[x])^2],
  • Covariance: Cov(x)=E[(xE[x])(xE[x])T]\mathrm{Cov}(\mathbf{x}) = \mathbb{E}[(\mathbf{x} - \mathbb{E}[\mathbf{x}])(\mathbf{x} - \mathbb{E}[\mathbf{x}])^T],
  • Jointly distributed random variables p(x,y)p(x, y), and,
    • Conditional distributions p(xy)=p(x,y)p(y)p(x | y) = \frac{p(x, y)}{p(y)},
    • Law of total probability (marginalization) p(x)=p(x,y) dyp(x) = \int p(x, y) \ dy,
    • Independent variables p(x,y)=p(x)p(y)p(x, y) = p(x) p(y).
    • Law of iterated/total expectations E[x]=E[E[xy]]\mathbb{E}[x] = \mathbb{E}[\mathbb{E}[x | y]].

Gaussian random variables are key to SDEs. A Gaussian (normal) random variable xN(μ,P)\mathbf{x} \sim \mathcal{N}(\mathbf{\mu}, \mathbf{P}) has density,

p(x)=exp(12(xμ)TP1(xμ))2πP1/2.p(\mathbf{x}) = \frac{\exp\left(-\frac{1}{2}(\mathbf{x} - \mathbf{\mu})^T \mathbf{P}^{-1} (\mathbf{x} - \mathbf{\mu})\right)}{|2\pi \mathbf{P}|^{1/2}}.

The most important property of Gaussian random variables is that any linear combination of Gaussian random variables is also Gaussian.

If x1N(μ1,P1)\mathbf{x_1} \sim \mathcal{N}(\mathbf{\mu_1}, \mathbf{P_1}) and x2N(μ2,P2)\mathbf{x_2} \sim \mathcal{N}(\mathbf{\mu_2}, \mathbf{P_2}), and A1\mathbf{A_1}, A2\mathbf{A_2}, and b\mathbf{b} are constants, then,

x=A1x1+A2x2+bN(μ,P),μ=A1μ1+A2μ2+b,P=A1P1A1T+A2P2A2T.\begin{align*} \mathbf{x} & = \mathbf{A_1} \mathbf{x_1} + \mathbf{A_2} \mathbf{x_2} + \mathbf{b} \sim \mathcal{N}(\mathbf{\mu}, \mathbf{P}), \newline \mathbf{\mu} & = \mathbf{A_1} \mathbf{\mu_1} + \mathbf{A_2} \mathbf{\mu_2} + \mathbf{b}, \newline \mathbf{P} & = \mathbf{A_1} \mathbf{P_1} \mathbf{A_1}^T + \mathbf{A_2} \mathbf{P_2} \mathbf{A_2}^T. \end{align*}

Introduction to Stochastic Processes

SDEs describe a class of stochastic processes (SDEs cannot describe all stochastic processes).

Definition 2 (Definition: Stochastic process)

A stochastic process is a family of (jointly distributed) random variables {x(t)}tT\{x(t)\}_{t \in T}.

Processes described by SDEs have continuous states xx and parameters tt.

For a given time, tt, we have stochastic variables, x(t)x(t). Note that we do not separate the notation for the stochastic/random variable and its realization.

Often, we also use a shorthand for its density, p(x,t)=p(x(t))p(x, t) = p(x(t)) and allow our notation for the argument to specify the density that we evaluate.

Convergence, Integrals and Mean Square Calculus

  • Convergence is an essential concept in real analysis.
  • Continuity: A function f(x)f(x) is continuous at aa if limxaf(x)=f(a)\lim_{x \to a} f(x) = f(a).
  • Derivative: If it exists, the derivative of ff at xx is,
f(x)limh0f(x+h)f(x)h.f^{\prime}(x) \triangleq \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}.
  • Riemann integrals:

Let P(t)P(t) be a partition of [a,b][a, b],

a=t0<t1<<tn=b,a = t_0 < t_1 < \ldots < t_n = b,

and let its norm be P=maxi(ti+1ti)|P| = \underset{i}{\max}(t_{i + 1} - t_i).

  • If the limit exists, the Riemann integral is,
abf(t) dtlimnP0i=0n1(ti+1ti)f(ti),\int_{a}^{b} f(t) \ dt \triangleq \lim_{\substack{n \to \infty \newline |P| \to 0}} \sum_{i = 0}^{n - 1} (t_{i + 1} - t_i) f(t_i^{\star}),

for any ti[ti,ti+1]t_i^{\star} \in [t_i, t_{i + 1}].

An example of a Riemann sum with  and error  of .
An example of a Riemann sum with and error of .

How is convergence defined?

A deterministic sequence xnRx_n \in \mathbb{R} converges to aa if ϵ>0,N\forall \epsilon > 0, \exists N,

xna2<ϵ,n>N.\Vert x_n - a \Vert_2 < \epsilon, \quad \forall n > N.

That is, for sufficiently large nn, xnx_n is roughly aa.

How should one define convergence for a sequence of random variables?

A few (decently) intuitive ways are,

The sequence of random variables xnx_n is said to converge to xx,

  • with probability 1 (almost surely) if,
Pr[limnxn(ω)=x(ω)]=1.Pr[\lim_{n \to \infty} x_n(\omega) = x(\omega)] = 1.
  • in mean square if,
limnE[(xnx)2]=0.\lim_{n \to \infty} \mathbb{E}[(x_n - x)^2] = 0.
  • in probability if for all ϵ>0\epsilon > 0,
limnPr[xn(ω)x(ω)>=ϵ]=0,\lim_{n \to \infty} Pr[\Vert x_n(\omega) - x(\omega) \Vert >= \epsilon] = 0,
  • in distribution if for all ARnA \subset \mathbb{R}^n,
limnPr[xnA]=Pr[xA].\lim_{n \to \infty} Pr[x_n \in A] = Pr[x \in A].

The “weakest” of these is convergence in distribution, and the “strongest” is convergence almost surely.

Warning (Convergence in distribution)

Suppose x,x1,x2,x, x_1, x_2, \ldots are independent and identically distributed, N(0,1)\mathcal{N}(0, 1).

The random sequence only converges in distribution,

limnPr[xnx]=Pr[xx].\lim_{n \to \infty} Pr[x_n \leq x] = Pr[x \leq x].
Warning (Convergence in almost surely, mean square, and in probability)

Suppose x,y1,y2,x, y_1, y_2, \ldots are independent and identically distributed, N(0,1)\mathcal{N}(0, 1).

The random sequence xn=x+ynnx_n = x + \frac{y_n}{n} converges to xnx_n in all senses.

Continuous and Differentiable Random Variables

Definition 3 (Definition: Continuous random functions (in mean square sense))

The random function is continuous in mean square at tt if,

l.i.mh0 x(t+h)=x(t),\underset{h \to 0}{\text{l.i.m}} \ x(t + h) = x(t),

where l.i.m\text{l.i.m} is limits in mean square.

Definition 4 (Definition: Differentiable random functions (in mean square sense))

The mean square derivative is,

x˙(t)l.i.mh0x(t+h)x(t)h,\dot{x}(t) \triangleq \underset{h \to 0}{\text{l.i.m}} \frac{x(t + h) - x(t)}{h},

if the limit exists.

Visualization of a random differentiable function.
Visualization of a random differentiable function.

Consider x(t)=a sin(t+ϕ)x(t) = a \ sin(t + \phi) where aunif[1,2]a \sim \text{unif}[1, 2] and ϕunif[0,2π]\phi \sim \text{unif}[0, 2\pi].

The random function is differentiable. Note that the derivative is itself random.

See Figure 7 for a visualization of the random function and its derivative at x=1x = 1.

Definition 5 (Definition: Mean square Riemann integrals)

Riemann integrals: As before, let P(t)P(t) be a partition of [a,b][a, b],

a=t0<t1<<tn=ba = t_0 < t_1 < \ldots < t_n = b

and let its norm be P=maxi(ti+1ti)|P| = \underset{i}{\max}(t_{i+1} - t_i). If the limit exists, the mean square Riemann integral is,

abx(t) dtl.i.mnP0i=0n1(ti+1ti)x(ti),\int_{a}^{b} x(t) \ dt \triangleq \underset{\substack{n \to \infty \newline |P| \to 0}}{\text{l.i.m}} \sum_{i=0}^{n-1} (t_{i+1} - t_i) x(t^{\star}_i),

for any ti[ti,ti+1]t^{\star}_i \in [t_i, t_{i+1}].

Visualization of a random integral.
Visualization of a random integral.

For x(t)=a sin(t+ϕ)x(t) = a \ sin(t + \phi), consider the integral,

π23π2x(t) dt.\int_{\frac{\pi}{2}}^{\frac{3\pi}{2}} x(t) \ dt.

Note, the integral is a random variable.

Summary

Most SDEs take the form,

dx(t)=f(x(t),t) dtdrift+L(x(t),t) dβ(t)diffusion,\begin{equation} dx(t) = \underbrace{f(x(t), t) \ dt}_{\text{drift}} + \underbrace{L(x(t), t) \ d\beta(t)}_{\text{diffusion}}, \end{equation}

where x(t)x(t) is a stochastic process and β(t)\beta(t) is a Brownian motion.

SDEs describe a class of stochastic processes useful in many areas (economics, physics, etc). Where we specifically (will) focus on (deep) generative models.

We can use mean square convergence to define convergence, derivates, and Riemann integrals for stochastic processes.

Equation (3) is shorthand for,

x(t)x(t0)=t0tf(x(s),s) ds+t0tL(x(s),s) dβ(s).x(t) - x(t_0) = \int_{t_0}^t f(x(s), s) \ ds + \int_{t_0}^t L(x(s), s) \ d\beta(s).

Note, we can use mean square Riemann integrals to define t0tf(x(s),s) ds\int_{t_0}^{t} f(x(s), s) \ ds but not t0tL(x(s),s) dβ(s)\int_{t_0}^{t} L(x(s), s) \ d\beta(s).

We need Itô calc for that ;).

Footnotes

  1. Wikipedia, Brownian Motion

  2. Wikipedia, Ornstein-Uhlenbeck Process

  3. Wikipedia, Black-Scholes Model

  4. Wikipedia, Lotka-Volterra equations

  5. Wikipedia, Itô calculus

  6. Wikipedia, σ\sigma-algebra

  7. Wikipedia, Probability Measure