🦅 Probability — Lévy Flight & Stable Distributions
Most random processes taught in introductory courses rely on distributions with well-defined mean and variance: Gaussian, Poisson, Binomial. But a large family of real-world phenomena follows distributions where the variance — or even the mean — is infinite. The new Lévy Flight simulation puts this directly in your hands.
Heavy tails and α-stable distributions
A distribution is called heavy-tailed if its tail decays as a power law: P(X > x) ~ x−α. For α ≤ 2 the variance is infinite; for α ≤ 1 the mean is also infinite. These are called α-stable (or Lévy stable) distributions and they are the only distributions that are closed under summation — the limit of sums of i.i.d. heavy-tailed variables is always a stable distribution (the Generalized Central Limit Theorem).
- α = 2: Gaussian distribution. The Central Limit Theorem applies. Random walk is Brownian.
- α = 1.5: Lévy distribution. Variance is infinite. Occasional very long jumps.
- α = 1.2: Very heavy tail. Extremely rare jumps dominate the total displacement.
- α → 1: Cauchy distribution limit. Mean is undefined; no characteristic scale.
The Mantegna algorithm
Generating samples from a stable distribution is non-trivial — there is no closed-form inverse CDF. The Mantegna (1994) algorithm provides an efficient approximation by combining two standard normal draws with a correction factor derived from the stability index α. The simulation implements this in real time for up to 8 simultaneous walkers.
Applications of Lévy statistics
Lévy flight and power-law step statistics appear across scales: the search patterns of foraging animals (albatrosses, sharks, bees), diffusion in turbulent plasmas, tick-by-tick stock price movements, human mobility from cell-phone data, earthquake displacement sequences, and photon free-path distributions in stellar atmospheres.
Related simulations in the probability category include Central Limit Theorem, Brownian Motion, and Random Walk.
🦅 Open Lévy Flight →🌿 Generative Art — Diffusion-Limited Aggregation
Diffusion-limited aggregation is a 1981 algorithm by Witten and Sander that produces visually striking fractal clusters from remarkably simple rules. Place a seed; release particles one at a time to random-walk until they stick. After thousands of particles the result is a branched, tree-like structure that defies intuitive expectation from such simple dynamics.
From simple rules to fractal geometry
The key insight is that the tips of the growing cluster are more likely to capture incoming random walkers than the re-entrant bays. This tip-splitting instability amplifies any initial asymmetry: once a branch is slightly longer, it captures more particles and grows still longer. The result is self-similar branching at every scale — the defining property of a fractal.
The fractal dimension D_f ≈ 1.71 means that DLA clusters are 71% of the way between a line (dimension 1) and a filled disk (dimension 2). This value has been confirmed in large-scale numerical experiments and is distinct from diffusion with a finite sticking probability (noise-reduced DLA), which approaches D_f = 2 as the sticking probability approaches zero.
Colour modes
The simulation offers four ways to visualize the cluster's history and structure:
- Age: earliest-stuck particles are hottest (red), recent particles are coolest (blue), revealing the growth history layer by layer.
- Distance: radius from the origin is mapped to hue, highlighting the circular symmetry and branch lengths.
- Heat: local particle density modulates colour, showing the difference in packing between branch tips and stems.
- Mono: single-colour flat fill, useful for printing or seeing the pure geometry without colour distraction.
Why DLA matters beyond art
DLA is a model for electrodeposition (dendrite formation in batteries), dielectric breakdown patterns (Lichtenberg figures), viscous fingering in porous media, mineral dendrite formation in rock fractures, and coral growth morphology. The same branching instability mechanism produces similar fractal geometries across these very different physical systems.
Related simulations in the generative art category include Barnsley Fern, Mandelbrot Set, and Chaos Game.
🌿 Open DLA Fractal →🌊 Fluid Dynamics — Shallow Water Equations
The shallow water equations (SWE) — also called the Saint-Venant equations after Adhémar Jean-Claude Barré de Saint-Venant who derived them in 1871 — are a fundamental model in geophysical fluid dynamics. They describe depth-averaged horizontal flow in bodies of water where the depth is much smaller than the horizontal scale.
Where the SWE apply
The SWE govern: tsunamis (whose wavelength of 100–200 km vastly exceeds ocean depth); storm surge and coastal flooding; tidal propagation in estuaries; dam-break flood waves; flow in irrigation channels and rivers; and atmospheric dynamics at synoptic scales. The assumptions (depth-averaged, hydrostatic pressure) fail only when the vertical velocity is significant — breaking waves, turbulent bores, and near-field dam breaks require the full 3D Navier–Stokes equations.
The Lax-Friedrichs scheme
The SWE form a nonlinear hyperbolic PDE system that can develop shock waves (bores, hydraulic jumps). The Lax-Friedrichs finite-difference scheme handles these naturally through its built-in numerical viscosity, which smooths the discontinuity over one to two grid cells. The trade-off is first-order spatial accuracy and slight over-smoothing of sharp fronts — acceptable for educational use and far simpler to implement than high-resolution schemes like MUSCL-Hancock or HLLE.
Four scenarios explained
- Dam Break: The Riemann problem. At t = 0 a barrier between two water columns of different height is removed. The exact analytic solution consists of a leftward-spreading rarefaction (continuous) and a rightward-propagating bore (shock). The simulation matches this qualitatively and converges to the exact solution as grid resolution increases.
- Sloshing: A cosine initial depth profile in a closed tank produces standing-wave oscillations. The fundamental period is T ≈ 2L / √(g·h̄), dependent on the mean depth. The wave damps slowly due to Manning friction and numerical viscosity.
- Tidal Wave: Sinusoidal inflow at the left boundary drives a progressive wave into still water. At subcritical Froude numbers the wave propagates rightward at speed c = √(gh). The frequency and period are visible in the velocity panel.
- Hydraulic Step: High-velocity inflow in the left third of the domain with a step up in bathymetry tests the scheme's handling of bed slope source terms and the transition between subcritical and supercritical flow.
The Froude number
The Froude number Fr = |u| / √(gh) plays the same role in shallow water flows as the Mach number in compressible aerodynamics. Fr < 1 is subcritical (tranquil flow); Fr > 1 is supercritical (rapid flow). The transition between the two is a hydraulic jump — an abrupt increase in depth and decrease in velocity, dissipating kinetic energy as turbulence. The velocity panel marks the Fr = 1 threshold with a dashed line.
Related simulations in the fluid dynamics category include Bernoulli Effect, Bénard Convection, and Boundary Layer.
🌊 Open Shallow Water Equations →Explore More Simulations
Browse all simulations in each category enriched by Wave 57: