Active Inference Institute · Pedagogical Study

Self-Organised Criticality:
a temporal grammar for the Bak–Tang–Wiesenfeld sandpile

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.

The canonical CRR formalism

CRR names three structural moments through which a self-organising system articulates itself in time. Each has a formal signature and a phenomenological reading.

1 ─ Coherence (the past, inside the temporal blanket)
C(x, t) = ∫ L(x, τ) dτ
Accumulated significance, integrated over lived time. L is the Fisher–Rao line element — the rate at which the system distinguishes itself from what it is not.
2 ─ Rupture (the now, the temporal blanket itself)
δ(now)   when  C · Ω = 1
The scale-invariant present moment — the Cramér–Rao saturation point, equivalent to the Heisenberg and Gabor limits, where inside matches outside and a transition becomes inevitable.
3 ─ Regeneration (the future, outside the temporal blanket)
R = ∫ φ(x, τ) · exp(C/Ω) · Θ(...) dτ
Reconstruction weighted by an exponential memory kernel. Moments of high coherence are exponentially amplified; Θ enforces causality; φ is the reconstruction resource available at each past moment.

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.

CRR as a temporal complement to the Free Energy Principle

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:

CRRFEPReading
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

What this demonstration shows

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.

Alexander Sabine · Active Inference Institute · temporalgrammar.ai · Alexander@activeinference.institute
Canonical BTW dynamics (Bak, Tang & Wiesenfeld, 1987; Dhar, 1990) under a CRR/FEP reading. Falsification of the strong-form CRR prediction is documented in the Tested tab.

Self-Organised Criticality

BTW · Live · CRR/FEP Annotated
Lattice L × L64
Grains dropped0
Avalanches0
Largest (topples)0
Mean height ⟨z⟩0.00
CV(ITI) tracked site

Parameters

Lattice size L64
Larger L exposes finite-size scaling
Drops / frame30

View

Run

§C: height z accumulating
§δ: z ≥ 4 rupture
§R: 4-neighbour redistribution

Avalanche size distribution — P(s)

Log–log; theoretical slope −1.27 shown dashed. BTW observable, not a CRR prediction.
bins: logarithmic MLE τ =

The pile tunes itself to its own critical point

Bak, Tang & Wiesenfeld, 1987 · Dhar, 1990

The rules

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.

What the pile does

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:

Avalanche size distribution P(s) ~ s−τ,   τ ≈ 1.27

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.

Why the demonstration is tiny

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.

Coherence, rupture, regeneration

Sabine · temporalgrammar.ai

The temporal grammar, at a site

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:

§C — Coherence Cn(t) = ∫ Ln(τ) dτ

The accumulation phase. Grains arrive, the height climbs, the site builds up distinguishability from its surroundings.

§δ — Rupture δ(now)   when zn reaches zc

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.

§R — Regeneration Rn = Σm Knm · φm

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.

The beauty function

CRR predicts a point of maximum expressive capacity at C* − Ω, where accumulated coherence is high and a small perturbation could go either way:

Beauty function B(C) = exp(C/Ω) · (C* − C)

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.

The Free Energy Principle

Friston · Parr, Pezzulo & Friston, 2022

Every site has a Markov blanket

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.

Precision and rupture

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.

"Precision-weighted prediction errors are the currency of belief updating. Where precision is high, errors matter greatly; where precision is low, they are damped." Parr, Pezzulo & Friston, 2022

Self-organisation without an agent

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.

What CRR adds to FEP

Spatial + Temporal Markov Blankets

FEP is spatial, CRR is temporal

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.

The split that SOC reveals

Self-organised criticality shows a striking asymmetry between the two blankets, which this demonstration measures directly:

  • Spatial blanket: bounded. The stationary distribution of site heights has a well-defined thermodynamic limit. ⟨z⟩, Var(z), and the shape of the local distribution are stable as the lattice grows. Ω derived from spatial observables sits at Ω ≈ 0.47.
  • Temporal blanket: unbounded. The distribution of inter-topple intervals at a single site does not have a thermodynamic limit. CV(ITI) grows roughly as 0.37 · ln(L), and the distribution is not exponential. The cycle is scale-free.

Why this is a CRR-native observation

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.

Tested — and where the test led

Pre-registration · Falsification · Retreat to description

The canonical prediction

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.

What the sandpile actually does

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:

L = 24 | CV(ITI) = 0.95
L = 32 | CV(ITI) = 1.05
L = 48 | CV(ITI) = 1.19
L = 64 | CV(ITI) = 1.30
L = 96 | CV(ITI) = 1.47

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.

The directional falsification

The strong-form CRR prediction is falsified for BTW. The observed deviation is directional, monotone, and matches the qualitative signature CRR itself labels as lying outside its natural domain. This is not a failure of the simulation or of the statistics; it is a structural incompatibility. The per-site cycle in BTW is scale-free by construction at the critical point, and CRR's canonical derivation assumes a geodesically-bounded cycle.

Phenomenological retreat: does Ω as a fitted parameter rescue the framework?

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 survives, and why it matters

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:

  • Spatial cycle: bounded, thermodynamic, has a stable Ω.
  • Temporal cycle: unbounded, critical, has no characteristic scale.

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.