Connect a diffusion model's random, jittering particles to the smooth density that describes them and you reach for one equation: Fokker-Planck. I use it each time I say the SDE and the distribution \( p_t \) are "the same story," or that the law of the noising process at each instant "is" \( p_t \). You write an SDE for one particle taking one noisy step after another. From Fokker-Planck you get the entire cloud of those particles as a single deterministic flow of probability. The link between the two and the shape of the equation both come from one fact about the roughness of Brownian motion, and I find that mystical.
Setup
Take a particle whose position \( X_t \in \mathbb{R}^d \) evolves according to
with a deterministic drift \( u_t \) and a random Brownian term \( \sigma_t\, dW_t \). Run this once and you get one jagged trajectory. Run it from many starting points, or many times over, and at each instant \( t \) the particle's position has a distribution; call its density \( p_t(x) \). The drift and the noise give you a rule for the particle. I want the law of motion for the density: a partial differential equation saying how \( p_t \) changes over time. That equation is the target,
and I derive it by starting from the particle and averaging over many runs.
Test functions
Going straight at \( p_t \) is awkward: you know how to push the particle forward in time, and you have no such rule for its density. I use a classic piece of misdirection instead, and it feels like cheating until the last step. Pick any smooth test function \( f : \mathbb{R}^d \to \mathbb{R} \), treat it as a probe, a measurement you take on the particle, then leave \( p_t \) alone and track how the average reading \( \mathbb{E}[f(X_t)] \) changes in time. You get two payoffs. From the particle's motion, you can compute how \( f(X_t) \) changes. And because
anything you learn about the average is a statement about \( p_t \), once you move the derivatives off \( f \) and onto \( p_t \) at the end. You measure the density through every possible probe, then remove the probes.
Taylor expanding one step
Freeze the particle at \( X_t \) and let it take one small step of duration \( h \). Discretize the SDE and the step is
with the drift contributing a clean \( h\, u_t \) and the noise contributing a Gaussian kick \( \Delta W \) of variance \( h \). The reading changes by \( f(X_t + \delta) - f(X_t) \). You Taylor expand because \( \delta \) is small, and you keep two orders:
Substitute \( \delta = h\, u + \sigma_t \Delta W \) (writing \( u = u_t(X_t) \) and \( A = \nabla^2 f(X_t) \) for the Hessian), and you get five pieces on the right-hand side:
Now average all five and see which ones remain.
The second-order term
Take the conditional expectation \( \mathbb{E}[\,\cdot \mid X_t] \): freeze the current position and average only over the fresh noise \( \Delta W \). With \( X_t \) fixed, you can treat \( u \), \( \nabla f \), and \( A \) as constants, and the only random object left is \( \Delta W \). From Brownian motion you have two facts about it,
Run down the five terms. The lone-\( \Delta W \) term (second) and the drift-noise cross term (fourth) each carry a single factor of \( \Delta W \), so they average to zero. The drift-drift term (third) is \( O(h^2) \), and you obliterate it when you divide by \( h \) and take the limit. The drift term (first) remains as \( h\, \nabla f^T u \). That leaves the last one, the noise-noise term, and it's the one I care about.
A product of two \( \Delta W \)'s looks negligible, but Brownian motion is confusing: \( \Delta W \) scales like \( \sqrt{h} \) rather than \( h \), so \( \Delta W^2 \) scales like \( h \), the same order as the drift. Make it precise with \( \Delta W = \sqrt{h}\, \varepsilon \), \( \varepsilon \sim \mathcal{N}(0, I_d) \), and the Gaussian quadratic-form identity \( \mathbb{E}[\varepsilon^T A \varepsilon] = \operatorname{tr}(A) \):
using \( \operatorname{tr}(\nabla^2 f) = \Delta f \), since the trace of the Hessian is the Laplacian. A term you would have thrown away remains as the Laplacian, and from it you get the entire diffusion half of Fokker-Planck.
The Ito term
\( \mathbb{E}[\Delta W^T \nabla^2 f\, \Delta W \mid X_t] = h\, \Delta f. \) Brownian motion has \( \sqrt{h} \) roughness, so a second-order term remains as a first-order one, and lo and behold, you have the Laplacian!
Taking the limit
Pick the gold out of the glitter and you have
Divide by \( h \) and let \( h \to 0 \). You lose the \( O(h^2) \) drift-drift term, and the left side becomes the time derivative of the average reading:
You now hold a complete description of the dynamics, told from the particle's side. To turn it into a statement about \( p_t \), write both expectations as integrals against the density,
Every derivative on the right still acts on the probe \( f \). Next, move them to \( p_t \).
Integration by parts
You do this with integration by parts, the powerhouse (mitochondria) of the whole derivation, and you need it for one thing: converting "derivatives of the probe" into "derivatives of the density." For the drift term, apply the identity \( \int \nabla f^T F\, dx = -\int f\, \operatorname{div}(F)\, dx \) with \( F = p_t u_t \) to get
The minus sign and the divergence have two sources: integration by parts flips a sign, and the sum of per-coordinate derivatives \( \sum_i \partial_i F_i \) is \( \operatorname{div}(F) \). For the diffusion term, integrate by parts twice (Green's identity), \( \int p_t \Delta f\, dx = \int f \Delta p_t\, dx \):
I slipped an assumption into both steps: the density and its gradient decay at infinity, so the boundary terms vanish. Densities with Gaussian tails, like the noised data distributions in a diffusion model, satisfy it. Put the two together and the whole right-hand side is a single integral with every derivative acting on \( p_t \):
Recovering the PDE
You have one thread left. The left side, \( \partial_t \mathbb{E}[f(X_t)] \), is also \( \partial_t \int f\, p_t\, dx = \int f\, \partial_t p_t\, dx \), since \( f \) does not depend on time. So
and this holds for every smooth test function \( f \). Two functions that agree when you integrate them against every test function must equal each other pointwise. Remove the probes and you are left with the equation:
Fokker-Planck
\( \partial_t p_t(x) = -\operatorname{div}\!\big(p_t(x)\, u_t(x)\big) + \dfrac{\sigma_t^2}{2}\, \Delta p_t(x). \)
Transport and diffusion
Read the two terms. The first, \( -\operatorname{div}(p_t u_t) \), is transport: the drift \( u_t \) carries probability mass around, the same continuity equation you write for a flowing fluid. The second, \( \tfrac{\sigma_t^2}{2} \Delta p_t \), is diffusion: the Laplacian, which comes from Brownian roughness, smooths and spreads the density, flattening peaks and filling valleys.
I call this the support vector of diffusion. I need it for the claim I make all over the five views, that the SDE's law at every instant is the distribution \( p_t \): you have one model, and this PDE is the deterministic description of the particle's random walk at the level of the density. It is also your doorway to the probability-flow ODE, where you take this same equation, fold the diffusion term into the transport term with \( \Delta p_t = \operatorname{div}(p_t \nabla \log p_t) \), and rewrite the noise term as a velocity. (Map the names back: there you will see the drift \( u_t \) written as \( f \), the noise \( \sigma_t \) as \( g \), and \( \Delta \) as \( \nabla^2 \).)
The best part of discovering this equation, for me, is that Planck gets to be popular for something besides the Planck constant...