A sandpile, fed one grain at a time, organises itself to the edge of catastrophe. Most grains land and do nothing. A few trigger avalanches of every size, with no characteristic scale. The pile tunes itself to its own critical point, without being told where that is. This is self-organised criticality (Bak, Tang & Wiesenfeld, 1987), and it sits at the meeting-point of statistical physics, biology, and the theory of self-organising systems. This demonstration runs the canonical sandpile and reads its internal structure through two complementary lenses: the Free Energy Principle, which gives the spatial grammar of inference and precision, and Coherence–Rupture–Regeneration (CRR), which adds a temporal grammar for accumulation, transition, and rebuilding.
CRR names three structural moments through which a self-organising system articulates itself in time. Each has a formal signature and a phenomenological reading.
The parameter Ω binds the three. Small Ω gives a rigid system that reconstitutes the same pattern (habit, crystal, pacemaker). Large Ω gives a flexible system open to transformation (insight, phase transition). At C · Ω = 1 the system achieves perfect self-characterisation and a rupture becomes the natural next step.
The Free Energy Principle (Parr, Pezzulo & Friston, 2022) provides a spatial grammar: a system maintains itself by minimising variational free energy across its Markov blanket, which partitions internal from external states. It tells us what updates and how precision is weighted. CRR places a complementary temporal Markov blanket across time — past, now, future — and supplies the grammar for when the updating ruptures into a new regime. The two frameworks share structure:
| CRR | FEP | Reading |
|---|---|---|
| C(x, t) | −F (negative free energy) | Accumulated evidence for the self-model |
| Ω | 1 / precision | Uncertainty, variance, or geodesic extent |
| δ(now) | Belief-update event | Perception-action transition, regime shift |
| R (regeneration) | Generative-model update | Posterior weighted by history |
| Spatial blanket | Markov blanket | Shared: inside / boundary / outside in space |
| Temporal blanket | — (not explicit) | Past / now / future: what CRR adds |
The sandpile below runs BTW dynamics. Each lens reveals a different feature of what is happening. FEP identifies every site as a node with its own local Markov blanket; avalanches propagate as cascading prediction errors. CRR reads each site as a temporal cycle: grains accumulating (C), the site toppling (δ), and the pile redistributing (R). Where CRR reaches its limit — and it does — the limit itself is informative. For SOC the spatial cycle is thermodynamically bounded while the temporal cycle is scale-free, and this asymmetry is a structural signature of the phenomenon. CRR makes that asymmetry expressible.
Where the grammar applies to the running code, it is marked with § tags. Where it does not, the tag is followed by a note explaining the boundary. The five tabs on the right of the running demonstration take each lens in turn.
A lattice of sites, each carrying an integer number of grains. At each timestep one grain is deposited at a uniformly random site. If the height at any site reaches the threshold zc = 4, that site topples: four grains leave it, one travelling to each of the four nearest neighbours. Topples may trigger further topples, so a single deposited grain can provoke an avalanche of any size. Grains that fall off the boundary are lost.
Left alone, the pile self-organises to a stationary state in which the mean height sits close to ⟨z⟩ ≈ 2.125 and avalanches occur at every scale. The probability of an avalanche of size s follows a power law:
No parameter was tuned. No external force drives the system to this point. The pile finds its own edge. Bak called this self-organised criticality, and it has since been proposed as a model for earthquakes, neural avalanches, forest fires, and biological evolution — though the applicability in each case is contested.
This simulation runs at L ranging from 32 to 128, which is small by physics standards. The BTW power-law is visible but finite-size cut off. The distribution plot on the left shows the live histogram as the pile runs.
Pick any interior site and watch only that site through time. Grains arrive (from direct deposition and from neighbour topples), the local height climbs, and at some moment the site topples. The pile then redistributes. CRR names the three structural moments of this cycle:
The accumulation phase. Grains arrive, the height climbs, the site builds up distinguishability from its surroundings.
The rupture. In the canonical CRR, rupture occurs when C · Ω = 1 — the Cramér–Rao saturation. In BTW the threshold is imposed by the toppling rule, so we observe this as z ≥ 4 rather than as a derived condition. That is a crucial distinction which the Tested tab returns to.
The redistribution. In BTW this is nearest-neighbour transfer with φ = 1; the full CRR kernel R = ∫ φ · exp(C/Ω) · Θ dτ collapses to this simple local rule because BTW has no memory weighting.
CRR predicts a point of maximum expressive capacity at C* − Ω, where accumulated coherence is high and a small perturbation could go either way:
For a site in BTW with z = 3 — one grain below threshold — the next deposition chooses between quiescence and a potentially large cascade. This is where SOC spends most of its time: poised, ready, one grain from transformation.
Each site in the lattice has internal states (its height z), external states (the heights of all non-neighbours), and a blanket formed by its four nearest neighbours. The neighbours are the only channel through which information flows in or out. This is a Markov blanket in the literal sense: the internal state is conditionally independent of the external world given the blanket.
Under FEP, a site maintains itself by minimising a quantity called variational free energy, which bounds surprise. The boundary is where precision — the inverse variance of expected signals — is assigned. Avalanches propagate as prediction errors cascading through the blanket.
In Parr, Pezzulo & Friston's formulation, there are two kinds of precision: likelihood precision on sensory data and transition precision on state evolution. Both come into play here. Sensory precision governs how the site weights incoming grains; transition precision governs how it expects its own state to evolve. When accumulated evidence overwhelms transition precision, the site shifts regime: it topples.
BTW sites do not have agency. They do not select actions. But the hierarchical structure of FEP — blanketed states nested within blanketed states — applies. The pile is a population of Markov blanketed sites coupled through shared boundaries. The emergence of criticality is then a collective property of the coupling, not an intention of any site.
FEP's Markov blanket partitions the world into inside, boundary, and outside — a spatial decomposition. CRR's Markov blanket partitions history into past, present, and future — a temporal decomposition. The two are complementary and symmetric.
For a single isolated event they give equivalent descriptions. For dynamical systems evolving through time, CRR articulates structure that FEP alone leaves implicit: the moment of rupture, the exponential weighting of past moments in reconstruction, and the beauty function's prediction of where the system spends its most expressive time.
Self-organised criticality shows a striking asymmetry between the two blankets, which this demonstration measures directly:
Standard SOC theory gives us the power-law exponent τ ≈ 1.27, the mean height 2.125, and the notion of critical self-tuning. It does not give us vocabulary for why the system is stable on one side (spatial) and diverges on the other (temporal). CRR's dual-blanket framing makes this asymmetry first-class. The spatial cycle is a bounded CRR cycle with a well-defined Ω; the temporal cycle is not bounded, because criticality is, by definition, the absence of a temporal scale.
This is what CRR adds to FEP here: not a new prediction, but a decomposition that separates what is bounded from what is not.
CRR nominates its own falsification condition. For a Z2 symmetry class without an SO(2) pacemaker — the simplest reading of a site cycling between charging and rupture — the coefficient of variation of inter-topple intervals should converge to CV = 1 as the system grows, via the identity CVZ2 · C*SO(2) = (1/2π)(2π) = 1.
We ran a numba-JIT BTW simulation at lattice sizes L ∈ {24, 32, 48, 64, 96} with tens of millions of deposition events, pooling inter-topple intervals from nine interior sites per run. The results:
CV does not converge. It grows, and closely tracks the logarithmic form CV ≈ 0.37 · ln(L) with R² = 0.997. The Gamma-shape parameter of the ITI distribution sits above 1 and drifts, so the distribution is not exponential either.
Four natural definitions of Ω — 1/⟨z⟩, Var(z), 1/⟨ITI⟩, and 2·CV(ITI) — disagree by a factor of roughly forty at L = 96. CRR's internal consistency requires one Ω satisfying both C · Ω = 1 and CV = Ω/2. These four do not converge. So: the phenomenological move does not rescue predictive content; it redistributes the failure.
What does survive is the dual-blanket description developed in the Together tab. CRR as vocabulary cleanly expresses the asymmetry that makes SOC what it is:
This is not a prediction — it is a decomposition. It tells us where to look rather than what to compute. That is a smaller claim than the topological derivation, but it survives honest testing and it is what CRR can contribute to the discussion of self-organising systems in the FEP lineage.
A framework that names its own falsification condition and then runs the test is doing the right thing. The boundary this test finds is a crisp one, and the work that remains is to use it well.