Drop grains of sand one at a time and watch the pile organize itself to the edge of chaos.
Drop grains of sand on a single spot. At first the pile just grows; once it gets steep, grains start to slide. A single grain can trigger anything from a trickle to an avalanche that rearranges the pile.
Bak, Tang, and Wiesenfeld (1987) turned this into a grid model. The pile doesn't need to be tuned: it evolves to a critical state on its own, with avalanches at every scale.
They called this self-organized criticality. No parameter is adjusted; the dynamics push the system to criticality and hold it there.
Each grid cell holds 0–3 grains. When a cell reaches 4, it topples: loses 4 grains, sends one to each of its four neighbors. Neighbors that reach 4 topple too. Grains off the edge are lost.
Click to drop a grain, or auto-drop. Early drops do nothing. Once most cells hold 2 or 3 grains, cascades begin — the transition to criticality.
Click on the grid to drop a grain
Colors encode grain count, lightest 0 to darkest 3. A red flash marks the site of a toppling.
"Abelian" because the final state is independent of drop order: dropping at A then B gives the same configuration as B then A. The commutativity gives the sandpile a clean algebraic structure.
At criticality, each avalanche size can be measured. Most drops trigger nothing; occasionally a drop sets off a chain involving thousands of cells.
The frequency vs. size plot on log-log scales is a straight line — a power law:
No characteristic scale: small, medium, and giant avalanches all follow the same relationship. There's no "typical" size — the signature of criticality.
Figure 1. Distribution of avalanche sizes on a log-log scale. Each dot is a bin of similar-sized avalanches. A straight line indicates a power law. The red dashed line is a least-squares fit. Drop at least a few thousand grains to see the distribution stabilize.
The theoretical exponent for the 2D sandpile is close to $\tau \approx 1$ for the probability density of avalanche sizes. You need a few thousand drops before the line stabilizes. Early on the pile is subcritical and most drops produce zero topplings. Once the grid is saturated, the power law emerges and holds.
Unlike a Gaussian where extreme events vanish, a power-law system makes large events rare but possible. A single grain can always trigger the largest avalanche yet seen. The model fits real-world phenomena where extreme events keep happening.
Recurrent sandpile configurations form a group under cell-wise addition and relaxation. The identity is the unique configuration that, added to any recurrent configuration and relaxed, leaves it unchanged.
On a square grid, the identity is a fractal: nested regions of 0, 2, and 3 grains at multiple scales. Compute it by relaxing a uniform high configuration (every cell at 6), adding 6 again, relaxing, and repeating to a fixed point.
Below is the identity for a smaller grid. Toggle to compare with the current pile state.
Figure 2. The identity element of the sandpile group on a $48 \times 48$ grid. Notice the four-fold symmetry and the fractal-like nested triangles. Larger grids produce even more intricate patterns.
Larger grids deepen the fractal detail. The pattern follows the boundary geometry: circular boundaries produce circular identities, triangular ones triangular. The boundary propagates inward through relaxation.
Mapping each drop to a tone with pitch and duration set by avalanche size makes the statistics audible. Small avalanches are quick high clicks; large ones are deep rumbles. No repeating pattern, but a recognizable texture.
Audio is off by default. Click Enable audio to initialize the WebAudio context (required by the browser), then drop grains or turn on auto-drop above. Every grain you drop plays a tone sized by the avalanche it triggers.
Figure 3. Sonification mapping. Pitch interpolates exponentially between min and max as avalanche size grows; larger cascades hold their tone longer.
To confirm the rhythmic character we hear, we can record a fresh run of a thousand drops and look at its power spectrum alongside two reference signals. White noise has a flat spectrum. A periodic signal has a single dominant peak. The sandpile sits between them: its spectrum slopes downward at roughly $-1$ on a log-log plot. That is 1/f noise, also called pink noise, and it is the spectral fingerprint of self-organized criticality.
Time series. Avalanche size for each successive grain drop.
Power spectrum. Log-log plot. A slope near $-1$ indicates 1/f noise.
1/f noise is everywhere once you start looking. It shows up in music, in the flow of the Nile, in the flicker of a candle flame, in the electrical activity of the brain. The sandpile produces it naturally, without tuning. What we hear is the same edge-of-chaos balance the power-law plot was drawing for us.
Finally, composition mode: record 30 seconds of whatever you do on the live pile above, then play it back. The replay uses the exact timings of your drops and the current mapping, so you can tweak pitch, decay, or timbre between listens.
Earthquakes, forest fires, stock market crashes, and even extinction events may follow power laws similar to the sandpile. Per Bak argued that self-organized criticality is nature's preferred operating state. Systems evolve to the edge where interesting things happen.
The sandpile is the simplest example. No one tunes a parameter. No one picks a critical temperature or coupling constant. The pile just builds until it is steep enough to avalanche, then holds itself at that boundary between order and chaos. Criticality is the attractor.