ID-5-02 (TO) · Mathematical Foundations of Diffusion Models · W03 demo
Two ways to draw from a distribution you can write down but cannot sample directly. One throws darts and keeps the good ones; the other walks. Neither ever estimates a density — and watching the second one converge is watching a probability distribution evolve in time.
The setup is Bayesian and deliberately minimal. The proposal is a standard normal prior; an observation at −1 supplies the likelihood; the target is the posterior they imply.
q(x) = N(x; 0, 1) · L(x) = exp(−(x+1)²/2s²) · p(x) ∝ q(x)L(x)
Draw a candidate from the prior, then accept it with probability L(x)/max L. Accepted points are distributed exactly as the posterior — no normalising constant is ever computed, and no density is ever estimated.
Darts under the envelope
Rejection sampling throws away work. A Markov chain instead moves: from the current point, draw each coordinate from its conditional given the others. For a bivariate normal with correlation ρ both conditionals are normal with known mean and standard deviation, which is exactly when Gibbs is available:
x | y ∼ N(ρy, 1−ρ²) y | x ∼ N(ρx, 1−ρ²)
One chain, walking
Now the part worth pausing on. Run 4,000 independent chains from the same starting point and ask not where any one of them is, but how they are distributed at step t. That distribution is a density evolving in time, and here it is known exactly:
xt | x0 ∼ N( ρ2t x0, 1 − ρ4t )
The distribution at step t
A chain is a time series, and its law obeys a differential equation. What you just watched — pt flowing toward p∞ — is the discrete-time shadow of the Fokker–Planck equation of Module 5. Langevin dynamics is the continuous version, and it needs only ∇x log p, the score. The forward process of a diffusion model is this same picture run deliberately in the easy direction; the reverse process is the hard one.