U2.2 6 min read Oct 2026

U2.2 Why Does the Average Crowd Transport the Whole Distribution?

Builds on3 notes

How do we know the field transports the right distribution?

Our reference paths connect the intended endpoint distributions. Generation, however, follows their learned average field rather than an individual reference path.

Why should that field still transport p0p_0 to p1p_1?

How does a velocity field change a distribution?

Density describes how crowded a neighborhood is, rather than the location of one particular person.

We should ask whether motion increases or decreases the mass inside a small region.

Divergence describes net outward flow

The divergence of velocity describes local expansion or compression. To track density, we must also account for how much mass occupies that location.

SupplementWhy sum directional derivatives?

Divergence adds the outward changes in velocity along each coordinate direction.

In two dimensions,

∇⋅v=∂v1∂x1+∂v2∂x2.\nabla\cdot v =\frac{\partial v_1}{\partial x_1} +\frac{\partial v_2}{\partial x_2}.

The two terms measure horizontal and vertical expansion:

  • ∇⋅v>0\nabla\cdot v>0: local volume expansion.
  • ∇⋅v<0\nabla\cdot v<0: local compression.
  • ∇⋅v=0\nabla\cdot v=0: no net local volume change.

In dd dimensions, sum ∂vi/∂xi\partial v_i/\partial x_i over coordinates. See M0.1 for flux and the divergence theorem.

A crowded corridor with slow movement need not carry many people per second. Nor does an almost empty corridor with fast movement. Throughput depends on both density and speed.

Their product is

pt(x)vt(x)p_t(x)v_t(x)

probability flux. In one dimension, density is probability per unit length and velocity is length per unit time:

(probabilitymeter)(metersecond)=probabilitysecond.\left(\frac{\text{probability}}{\text{meter}}\right) \left(\frac{\text{meter}}{\text{second}}\right) =\frac{\text{probability}}{\text{second}}.

The product is probability crossing a location per unit time.

For a small interval, compare incoming flux at the left boundary with outgoing flux at the right. More outflow decreases the enclosed mass.

Net outward flux per unit volume is the divergence of flux:

∇⋅(pt(x)vt(x)).\nabla\cdot\bigl(p_t(x)v_t(x)\bigr).

Positive net outflow requires falling density:

∂tpt(x)=−∇⋅(pt(x)vt(x)),\partial_t p_t(x) =-\nabla\cdot\bigl(p_t(x)v_t(x)\bigr),

or equivalently,

∂tpt(x)+∇⋅(pt(x)vt(x))=0.\boxed{ \partial_t p_t(x)+\nabla\cdot\bigl(p_t(x)v_t(x)\bigr)=0. }

This is the continuity equation: mass changes through movement across boundaries, without appearing or disappearing.

Try itDerive the one-dimensional inflow-minus-outflow equation

A short interval [x,x+Δx][x,x+\Delta x] has mass approximately pt(x)Δxp_t(x)\Delta x. Its change per unit time is

∂tpt(x)Δx=pt(x)vt(x)−pt(x+Δx)vt(x+Δx).\partial_t p_t(x)\Delta x =p_t(x)v_t(x)-p_t(x+\Delta x)v_t(x+\Delta x).

Divide by Δx\Delta x and take the limit:

∂tpt(x)=−∂x(pt(x)vt(x)).\partial_t p_t(x)=-\partial_x\bigl(p_t(x)v_t(x)\bigr).

In higher dimensions, replace endpoints by a closed boundary and the derivative by divergence.

Add the conservation laws for the conditional groups

Let Z=(X0,X1)Z=(X_0,X_1) denote an endpoint pair. Given Z=zZ=z, consider a conditional probability path pt(x∣z)p_t(x\mid z) with velocity ut(x∣z)u_t(x\mid z).

Mixing the pairs gives the intended marginal path:

pt(x)=∫pt(x∣z)p(z) dz.p_t(x)=\int p_t(x\mid z)p(z)\,\mathrm dz.

The crowd average can be written as

vt(x)=∫ut(x∣z)pt(x∣z)p(z)pt(x) dz=E[ut(x∣Z)∣Xt=x].v_t(x) =\int u_t(x\mid z) \frac{p_t(x\mid z)p(z)}{p_t(x)}\,\mathrm dz =\mathbb E[u_t(x\mid Z)\mid X_t=x].

Its posterior weights select paths compatible with the current location and time.

Substitute the marginal density and flux into the continuity equation:

∂tpt+∇⋅(ptvt)=∫[∂tpt(x∣z)+∇⋅(pt(x∣z)ut(x∣z))]p(z) dz=0.\begin{aligned} \partial_t p_t+\nabla\cdot(p_tv_t) &=\int \left[ \partial_t p_t(x\mid z) +\nabla\cdot\bigl(p_t(x\mid z)u_t(x\mid z)\bigr) \right]p(z)\,\mathrm dz\\ &=0. \end{aligned}

Each conditional path conserves mass, so the integrated expression vanishes.

Average the conditional fluxes, and the resulting velocity transports the correct marginal path.

This justifies Conditional Flow Matching [1]. Generated particles need not retrace individual training paths; they solve the ODE driven by the marginal field, using the neural-ODE viewpoint [2]:

dxtdt=vt(xt),X0∼p0.\frac{\mathrm d x_t}{\mathrm dt}=v_t(x_t),\qquad X_0\sim p_0.

Under the regularity and uniqueness conditions below, the terminal distribution is p1p_1.

SupplementA weak proof that also handles singular conditional paths

We can prove the result directly from random reference paths, without assuming each conditional law has a density.

Let Xt=It(Z)X_t=I_t(Z), define its law ptp_t, and set

vt(x)=E[X˙t∣Xt=x].v_t(x)=\mathbb E[\dot X_t\mid X_t=x].

For a smooth compactly supported test function ϕ\phi,

ddtE[ϕ(Xt)]=E[∇ϕ(Xt)⋅X˙t]=E[∇ϕ(Xt)⋅vt(Xt)]=∫∇ϕ(x)⋅vt(x)pt(x) dx.\begin{aligned} \frac{\mathrm d}{\mathrm dt}\mathbb E[\phi(X_t)] &=\mathbb E[\nabla\phi(X_t)\cdot\dot X_t]\\ &=\mathbb E[\nabla\phi(X_t)\cdot v_t(X_t)]\\ &=\int \nabla\phi(x)\cdot v_t(x)p_t(x)\,\mathrm dx. \end{aligned}

Use the chain rule followed by conditional expectation. Integration by parts gives the weak continuity equation:

∂tpt+∇⋅(ptvt)=0.\partial_t p_t+\nabla\cdot(p_tv_t)=0.

This also covers deterministic conditional paths represented by Dirac measures. If the resulting field is regular enough to uniquely determine the transported law, its ODE marginals equal the reference marginals.

SupplementHow do CFM and ideal FM losses differ?

If the marginal velocity were available, we could train with

LFM=E∥vθ(Xt,t)−vt(Xt)∥2.\mathcal L_{\mathrm{FM}} =\mathbb E\|v_\theta(X_t,t)-v_t(X_t)\|^2.

CFM uses conditional labels instead. Expanding the square and conditioning gives

LCFM=LFM+E tr Var[ut(Xt∣Z)∣Xt].\mathcal L_{\mathrm{CFM}} =\mathcal L_{\mathrm{FM}} +\mathbb E\,\mathrm{tr}\,\mathrm{Var} \bigl[u_t(X_t\mid Z)\mid X_t\bigr].

The extra variance term is independent of θ\theta, so the gradients and minimizers agree. It measures conflicting reference labels at the same input.

SupplementDoes a density path determine a unique velocity?

No. If ∇⋅(ptwt)=0\nabla\cdot(p_tw_t)=0, then vt+wtv_t+w_t gives the same density evolution. A circular crowd can rotate without changing its density.

The continuity equation determines distribution evolution without uniquely fixing sample trajectories. This freedom becomes a sampling-efficiency issue in the next unit.

Check your understanding

Check your understanding

What happens where ∇⋅(ptvt)>0\nabla\cdot(p_tv_t)>0?

Check your understanding

Why does posterior-averaged velocity preserve the marginal path?

References

  1. Lipman, Y., Chen, R. T. Q., Ben-Hamu, H., Nickel, M., Le, M. Flow Matching for Generative Modeling. ICLR 2023. Theorems 1 and 2.
  2. Chen, R. T. Q., Rubanova, Y., Bettencourt, J., Duvenaud, D. Neural Ordinary Differential Equations. NeurIPS 2018.