Flow Matching, ODEs, and Euler's Method
The target distribution is a 2D smiley face built from sampled points along a circle (face outline), two dots (eyes), and an arc (mouth), each perturbed with small Gaussian noise.
Particles follow straight-line (linear interpolation) paths from noise (t=0) to data (t=1): xt = (1−t) x0 + t x1
The learned velocity field v(xt, t) = x1 − x0 shown as arrows on a grid. Arrows point from the current interpolated position toward the target. Drag the slider to see how the field changes with time.
Starting from noise, we integrate dx/dt = v(x, t) via Euler's method to generate new samples that match the target distribution.
Analytical solution: x(t) = x(0) · e−t. Drag the slider to change the initial condition.
Compare the true solution x(t) = x(0) e−t with Euler steps x(t+Δt) = x(t) + Δt · f(x, t). Larger step sizes yield less accurate (and eventually unstable) approximations.
Euler approximations with step sizes Δt ∈ {0.1, 0.5, 1.0, 1.5, 2.0, 2.5}. For Δt > 2 the method becomes unstable and oscillates.
Made with ❤️ by Mark Žnidar