Notation: t is forward diffusion time; u = T − t is reverse time; τ is Langevin temperature; st is the score; s without a subscript is the interpolation parameter. Brownian motions B and W have covariance tI. All numerical exhibits are low-dimensional teaching models.
1 / Forward diffusion and denoising
A discrete variance-preserving chain gradually adds Gaussian noise. Let αk = 1−βk and ᾱk = ∏j≤k αj. Then
q(xk|x₀) = 𝒩(√ᾱkx₀, (1−ᾱk)I).
Sample k, x₀, and ε ∼ 𝒩(0,I); form xk = √ᾱkx₀ + √(1−ᾱk)ε. A common DDPM objective is
ℒsimple = 𝔼 ‖ε − εθ(xk,k)‖².
This noise-prediction loss is a simplified weighting of the variational training objective. At its population optimum, εθ estimates 𝔼[ε|xk], giving the marginal score
sθ(xk,k) ≈ −εθ(xk,k) / √(1−ᾱk).
Continuous-time exhibit: β(t)=1, ᾱ(t)=e⁻ᵗ. A single Gaussian perturbation gives the correct noisy marginal, but does not by itself specify a Brownian trajectory. [1]
2 / Reverse SDE and probability-flow ODE
For dXt = f(Xt,t)dt + g(t)dWt, define st = ∇ log pt. Assuming sufficient smoothness and positive densities, in the increasing reverse clock u = T−t:
dYu = [−f(Yu,t) + g(t)²st(Yu)]du
+ g(t)dBu.
The corresponding probability-flow ODE in that same clock is
dY/du = −f(Y,t) + ½g(t)²st(Y).
The half factor matters. Substituting stpt = ∇pt into the Fokker–Planck equation yields an equivalent continuity equation with velocity f − ½g²s in forward time.
Exact scores and consistent initialization give matching marginals, not identical paths. Approximate scores and time discretization introduce error. These formulas assume scalar, state-independent g. [2]
3 / From Langevin particles to density evolution
dX = −∇V(X)dt + √(2τ)dB
∂tρ = ∇·(ρ∇V) + τΔρ.
The second equation is Fokker–Planck: drift transports probability and Brownian noise spreads it. The probability flux is J = −ρ∇V − τ∇ρ. If Z = ∫e−V/τdx is finite, π = Z⁻¹e−V/τ has zero flux.
Euler–Maruyama gives the unadjusted Langevin update
Xn+1 = Xn − h∇V(Xn) + √(2τh)ξn.
Finite h generally biases the stationary law. The quartic example uses a small h for illustration, not a theorem of numerical convergence. Stability and mixing depend on the potential, step size, and initial law.
4 / Free energy as the organizing principle
ℱ(ρ) = ∫ Vρ dx + τ∫ ρ log ρ dx
ℱ(ρ) − ℱ(π) = τ KL(ρ ‖ π).
The first term favours low potential; the second favours spreading. With first variation δℱ/δρ = V + τ(logρ+1), the density equation becomes
∂tρ = ∇·(ρ∇[δℱ/δρ]).
For smooth positive solutions with adequate decay or no-flux boundaries, integration by parts gives
dℱ/dt = −∫ ρ |∇(V+τ logρ)|² dx ≤ 0.
This is the Wasserstein gradient-flow structure. Under a globally λ-strongly convex potential (λ>0), suitable solutions satisfy W₂(ρt,π) ≤ e−λtW₂(ρ₀,π). The double-well exhibit does not meet that convexity condition. [3]
5 / What geometry adds — and what it does not say
For probability measures with finite second moments, quadratic Wasserstein distance is the least root-mean-square cost of coupling their mass:
W₂²(μ,ν) = infγ∈Π(μ,ν) ∫ |x−y|² dγ(x,y).
The dynamic formulation describes the same cost through a continuity equation: minimize ∫₀¹∫ρ|v|² dx ds subject to ∂sρ + ∇·(ρv)=0 and fixed endpoints. It connects particle velocity to motion through distribution space.
JKO replaces a small Euclidean gradient step with a minimization involving W₂²/(2h) and ℱ. The Gaussian experiment above makes this construction directly computable. Its time-discrete iterates approximate a gradient-flow curve as the step shrinks.
A diffusion-model score is an ordinary spatial gradient of log density. “Wasserstein gradient” refers to a different object: variation of a functional over distributions. The language is connected, but the two gradients are not interchangeable.
The Ricci-flow connection is a viewpoint: study an evolving geometric object through a governing flow. Here that object is a probability distribution; the simulations do not compute curvature or implement Ricci flow. [4]
The app works without an internet connection. These links open the underlying papers when you are online.
Numerical methods & reproducibility
The diffusion lab uses 640 particles and a 64-component Gaussian mixture. Forward OU transitions are exact. Reverse SDE integration is Euler–Maruyama; the probability-flow ODE uses Heun's method. A quadratic reverse-time grid resolves the low-noise end. Time horizon T=6, 360 steps, 121 stored frames.
The Langevin lab has 800 particles, a fixed step h=0.005, and seed 81 on reset. Its quartic potential is not globally Lipschitz. If a nonfinite state or |x|>20 occurs, the simulation stops and reports instability; particles are not clipped to manufacture convergence. The target normalization uses numerical quadrature on [−6,6].
The transport lab uses midpoint quantiles, bisection of analytic Gaussian-mixture CDFs, and a small Gaussian display kernel. W₂ is computed from the unsmoothed quantiles. JKO statistics follow the closed-form Gaussian update.
The Noise → shape walkthrough uses 600 samples, a 64-component mixture with σ₀=0.08, horizon T=12, and 480 steps on a quadratic time grid. The default initialization is exactly N(0,I); exact p₁₂ initialization is optional. Heun and Euler–Maruyama implement the displayed ODE and SDE. The forward slider couples marginal samples with fixed noise; it is not a Brownian trajectory. The score probe evaluates the analytic density and posterior, with a rescaled density background for display. Seeds initialize a deterministic pseudorandom generator; Gaussian draws use Box–Muller. No network requests, model downloads, telemetry, or external scripts are needed.