Guide To AI LogoGuide To AI
Unit 17

Stochastic Dynamics

modeling randomness through time-dependent processes, differential equations, and sampling techniques

Core Concepts Covered

  • Markov processes and time-dependent stochastic systems
  • Stochastic Differential Equations (SDEs) and diffusion models
  • Sampling methods: Monte Carlo and MCMC

1. Markov Processes and Stochastic Chains

In many machine learning applications (such as sequence generation, reinforcement learning, or generative diffusion models), physical states evolve over time with an element of randomness. We model these time-dependent noisy systems using Stochastic Processes.

The Markov Property: A stochastic process has the Markov property (or is 'memoryless') if its future state depends strictly on its *present* state, and is independent of its entire past history. Formally:

P(Xt+1=xt+1Xt=xt,Xt1=xt1,...,X0=x0)=P(Xt+1=xt+1Xt=xt)P(X_{t+1} = x_{t+1} | X_t = x_t, X_{t-1} = x_{t-1}, ..., X_0 = x_0) = P(X_{t+1} = x_{t+1} | X_t = x_t)

Markov Chains: Discrete-time Markov processes operating on discrete state spaces. We represent transition probabilities from any state ii to jj inside a square Transition Matrix PP where rows sum to exactly 1.01.0.

Weather Chain Example: Suppose we have a 2-state weather system: Sunny (SS) and Rainy (RR). Let the transition matrix be:

P=[0.80.20.40.6]P = \begin{bmatrix} 0.8 & 0.2 \\ 0.4 & 0.6 \end{bmatrix}

This means if today is Sunny, there is an 80%80\% chance tomorrow is Sunny, and a 20%20\% chance it rains. If today is Rainy, there is a 40%40\% chance tomorrow is Sunny. Over infinite days, the weather probabilities settle into a stable Stationary Distribution π=[πS,πR]\pi = [\pi_S, \pi_R] satisfying πP=π\pi P = \pi:

[πSπR][0.80.20.40.6]=[πSπR]\begin{bmatrix} \pi_S & \pi_R \end{bmatrix} \begin{bmatrix} 0.8 & 0.2 \\ 0.4 & 0.6 \end{bmatrix} = \begin{bmatrix} \pi_S & \pi_R \end{bmatrix} 0.8πS+0.4πR=πS    0.4πR=0.2πS    πS=2πR0.8\pi_S + 0.4\pi_R = \pi_S \implies 0.4\pi_R = 0.2\pi_S \implies \pi_S = 2\pi_R Since probabilities must sum to 1 (πS+πR=1\pi_S + \pi_R = 1), we solve: 2πR+πR=1    πR=13,πS=232\pi_R + \pi_R = 1 \implies \pi_R = \frac{1}{3}, \pi_S = \frac{2}{3}. Thus, over infinite time, the climate is guaranteed to be Sunny 66.7%66.7\% of the time, regardless of today's weather!

2. Stochastic Differential Equations & Langevin Dynamics

While standard calculus models smooth, deterministic curves, physical systems fluctuate randomly. We model continuous-time noisy trajectories using Stochastic Differential Equations (SDEs).

An SDE adds a stochastic noise term (governed by a Brownian motion / Wiener process WtW_t) to a standard deterministic differential equation: dXt=f(Xt,t)dt+g(Xt,t)dWtdX_t = f(X_t, t)dt + g(X_t, t)dW_t

where f(Xt,t)f(X_t, t) represents the deterministic drift (forces pulling the system toward a trend), and g(Xt,t)g(X_t, t) represents the stochastic diffusion (fluctuations or noise surrounding the trend).

Langevin Dynamics: A specialized SDE modeling the physical thermal motion of particles suspended in fluid. In machine learning, Langevin dynamics is incredibly powerful because it allows us to draw samples from highly complex, unnormalized probability distributions p(x)p(x) using only their gradients (the 'score' function xlnp(x)\nabla_x \ln p(x)): dxt=12xlnp(xt)dt+dWtdx_t = \frac{1}{2} \nabla_x \ln p(x_t) dt + dW_t By taking derivative steps towards high-probability densities while injecting continuous Wiener noise dWtdW_t, the path explores and samples the entire target distribution safely.

3. Sampling Methods & Denoising Diffusion Models

In Generative AI, we often need to generate samples from highly complex, high-dimensional probability distributions (like the distribution of all realistic human faces).

Monte Carlo Sampling: Simulates random experiments repeatedly to approximate deterministic parameters (for instance, estimating the area of a circle by throwing random darts inside a bounding square).

Markov Chain Monte Carlo (MCMC): A class of algorithms (like Metropolis-Hastings) that constructs a custom Markov chain whose stationary distribution is exactly our target distribution p(x)p(x), allowing us to sample from complex spaces by walking along the chain.

Denoising Diffusion Probabilistic Models (DDPM): The stochastic foundation behind modern generative image models. A forward diffusion process gradually degrades an input image into pure Gaussian noise by adding noise in tiny SDE steps. The model then learns a reverse process—using neural networks to estimate and subtract noise at each step, stochastically regenerating highly realistic images from pure noise.

Interactive Practice Quiz

Test your understanding with instant feedback

QUESTION 01

Which of the following defines the core characteristic of the 'Markov Property'?

QUESTION 02

What does the 'Stationary Distribution' π\pi of a Markov chain represent?

QUESTION 03

In a Stochastic Differential Equation (SDE) dXt=f(Xt,t)dt+g(Xt,t)dWtdX_t = f(X_t, t)dt + g(X_t, t)dW_t, what does the term dWtdW_t represent?

QUESTION 04

How does Langevin Dynamics allow machine learning models to sample from a complex probability distribution p(x)p(x)?

QUESTION 05

In generative Denoising Diffusion Models (DDPM), what occurs during the 'reverse process'?

QUESTION 06

What is a 'Stochastic Process'?

QUESTION 07

In the Stochastic Differential Equation dXt=f(Xt,t)dt+g(Xt,t)dWtdX_t = f(X_t, t)dt + g(X_t, t)dW_t, what does the function f(Xt,t)f(X_t, t) represent?

QUESTION 08

What is the core idea behind 'Monte Carlo' sampling methods?

QUESTION 09

Why do we use Markov Chain Monte Carlo (MCMC) algorithms like Metropolis-Hastings in probabilistic machine learning?

QUESTION 10

In Langevin SDE dxt=12xlnp(xt)dt+dWtdx_t = \frac{1}{2} \nabla_x \ln p(x_t) dt + dW_t, what role does the score function xlnp(xt)\nabla_x \ln p(x_t) play?