Simulations

Simulations


The Wiener Process

The Wiener process WtW_t is the scaling limit of a random walk, characterized by four properties:

  1. W0=0W_0 = 0 a.s.
  2. Independent increments: WtWsFsW_t - W_s \perp \mathcal{F}_s for t>st > s.
  3. Gaussian increments: WtWsN(0,ts)W_t - W_s \sim \mathcal{N}(0, t-s).
  4. Continuous paths a.s.
Theorem (Lévy's Construction).

The Wiener process can be constructed via the Karhunen-Loève expansion:

Wt=tZ0+n=12πnZnsin(nπt)W_t = t \cdot Z_0 + \sum_{n=1}^\infty \frac{\sqrt{2}}{\pi n} Z_n \sin(n \pi t)

where ZnN(0,1)Z_n \sim \mathcal{N}(0, 1) are i.i.d. The series converges uniformly on [0,1][0, 1] a.s.

Despite being continuous, WtW_t is nowhere differentiable. The graph has Hausdorff dimension 3/23/2; the path in 2\ge 2 dimensions fills space with dimension 22. The self-similarity 1cWct=dWt\frac{1}{\sqrt{c}} W_{ct} \stackrel{d}{=} W_t is behind its appearance across scales in physics and finance.

Fig 1.1: 2D Brownian Motion (Wiener Process)

The Ising Model

Spins σi{1,+1}\sigma_i \in \{-1, +1\} on a lattice Λ\Lambda, with Hamiltonian

H(σ)=Ji,jσiσjH(\sigma) = -J \sum_{\langle i, j \rangle} \sigma_i \sigma_j

and Gibbs measure μ(σ)=1ZeβH(σ)\mu(\sigma) = \frac{1}{Z} e^{-\beta H(\sigma)}.

In d2d \ge 2 there is a critical temperature TcT_c. Above TcT_c correlations decay exponentially (paramagnetic phase). Below TcT_c the system magnetizes spontaneously.

Theorem (Peierls Argument (1936)).

For sufficiently low temperatures in 2D, the ordered state is stable. A domain wall of length LL costs energy 2JL2JL, while the number of such contours grows as 3L3^L. The probability of a contour is bounded by (3e2βJ)L(3 e^{-2\beta J})^L, which is summable for large β\beta.

Near Tc2.269T_c \approx 2.269 (Onsager), observables follow power laws: m(TcT)βm \sim (T_c - T)^\beta, χTTcγ\chi \sim |T - T_c|^{-\gamma}. The exponents depend on dimension but not on lattice details (universality).

Temperature: 2.27Critical
Fig 1.2: 2D Ising Model (Draw to Magnetize)

The Galton Board

Each ball bounces left or right with p=1/2p=1/2 at every peg. The final position is X=i=1NBiX = \sum_{i=1}^N B_i, a sum of independent Bernoulli trials.

Theorem (De Moivre-Laplace Theorem).

As NN \to \infty:

(Nk)pk(1p)Nk12πNp(1p)exp((kNp)22Np(1p))\binom{N}{k} p^k (1-p)^{N-k} \approx \frac{1}{\sqrt{2\pi N p(1-p)}} \exp \left( - \frac{(k - Np)^2}{2 N p(1-p)} \right)

In the continuum limit, the particle density u(x,t)u(x, t) satisfies the heat equation tu=DΔu\partial_t u = D \Delta u. The Gaussian is its Green’s function — the density that maximizes entropy subject to a variance constraint.

Fig 1.3: Galton Board (Central Limit Theorem)

Geodesics on Curved Manifolds

On a Riemannian manifold (M,g)(M, g), a geodesic γ(t)\gamma(t) satisfies the equation

d2xkdt2+Γijkdxidtdxjdt=0\frac{d^2 x^k}{dt^2} + \Gamma^k_{ij} \frac{dx^i}{dt}\frac{dx^j}{dt} = 0

where Γijk\Gamma^k_{ij} are the Christoffel symbols of the Levi-Civita connection. On surfaces of constant positive curvature (S2S^2), geodesics are great circles. On the torus T2T^2, Gaussian curvature K=cosθ/(R+rcosθ)rK = \cos\theta / (R + r\cos\theta)r changes sign, positive on the outer equator, negative on the inner, zero at top and bottom. On a saddle (hyperbolic paraboloid), K<0K < 0 everywhere and geodesics diverge.

Vertices are colored by Gaussian curvature, warm tones for K>0K > 0 and cool tones for K<0K < 0.

K > 0 outer, K < 0 inner, K = 0 top/bottom0 geodesics
Fig G.1: Geodesic Explorer (Double-Click Surface to Add Geodesics)

Weather-Driven Flow

A particle system with drift and diffusion set by live weather from Chapel Hill, NC (Open-Meteo API). Wind velocity (vx,vy)(v_x, v_y) determines the mean drift, temperature TT scales the diffusion coefficient σ2(TT0)+\sigma^2 \propto (T - T_0)^+, precipitation adds a gravitational component, and cloud cover modulates particle density.

Fig L.1: Weather-Driven Particle Field (Live)

Ornstein-Uhlenbeck on Live Forecast

The 24-hour temperature forecast μ(t)\mu(t) for Chapel Hill serves as the mean function for a time-inhomogeneous Ornstein-Uhlenbeck process:

dXt=θ(μ(t)Xt)dt+σdWtdX_t = \theta(\mu(t) - X_t) \, dt + \sigma \, dW_t

The stationary variance Var(Xt)=σ22θ(1e2θt)\text{Var}(X_t) = \frac{\sigma^2}{2\theta}(1 - e^{-2\theta t}) gives the 2σ2\sigma confidence band. The forecast curve is deterministic, the sample paths are stochastic. Real data from Open-Meteo.

Fig L.2: Ornstein-Uhlenbeck Paths on Live Forecast (Live)

Bayesian Visitor Profile

A Dirichlet prior Dir(α1,,α6)\text{Dir}(\alpha_1, \ldots, \alpha_6) over six interest categories, updated from scroll position and visible content. Each observation increments the corresponding αi\alpha_i and the posterior mean E[πi]=αi/jαj\mathbb{E}[\pi_i] = \alpha_i / \sum_j \alpha_j concentrates as evidence accumulates, with credible intervals narrowing at O(1/n)O(1/\sqrt{n}). State persists in localStorage.

Fig L.3: Bayesian Visitor Profile (Live)