Active Inference InstituteSimulations

Chapters 1–3BeginnerNew edition

Ink that keeps its form

A drop of ink in still water spreads until it is everywhere. Give the same particles, with the same random jostling, a flow that carries them back towards likely places, and the ink keeps its form. Things that persist counter random fluctuations with their average flow, and so keep the entropy of their states bounded.

How hard the water jostles each particle. A setting.
Flow along the contours of surprisal. Acts only when the flow is on.

Tap or click the water to drop ink where you like. Time and length are in arbitrary units; entropy is in nats.

Learn by doing

Try this

  1. Drop ink into passive water. Before you press: will the entropy level off before the ink reaches the walls? Watch the measured curve follow the prediction for a spreading Gaussian cloud, and keep climbing towards ln 640. In passive water nothing depends on where the ink is, so nothing brings it back.
  2. The same drop and the same noise, now with a flow. Each particle gets exactly the random kicks it got in step 1. The only change is a drift down the gradient of surprisal. Predict where the entropy will settle, then compare the three numbers: measured entropy, entropy of the steady state, and surprisal averaged along paths.
  3. Raise the noise. The fluctuations become three times stronger. Will the cloud grow? It does not: in a system with this steady state the flow that counters the fluctuations must grow with them. Then switch to passive water and back, and watch the ink disperse and gather again.
  4. Add solenoidal flow. Now the ink circulates along the contours of surprisal. Predict what happens to the entropy and to the shape of the cloud. Both stay as they were. Only the turning changes, and it equals 2q.
  5. Change the shape of the steady state. With two basins the ink first fills the nearer one, then leaks across the saddle until both hold the same amount. The followed path wanders from basin to basin. The form is more complex; the rule is the same.
  6. Draw a boundary. The last panel asks what it takes for one part of a system to be set apart from another. Predict whether two variables that never touch can still be correlated.

From the textbook

Figure 3.3, drawn again

One particle starts at (5, 5) in each system. Both receive the same sequence of random kicks, number for number. On the left the particle also follows the flow; in the middle it does not. The settings are those of the dish above.

Left: Path taken by a 2-dimensional random dynamical system with a (nonequilibrium1) steady state. This can be interpreted as minimizing its surprise, which is shown in the contour plot on the right. Right: The center is the least surprising region; the circles moving away from the center represent progressively more surprising regions. Middle: In contrast, this plot shows the trajectory of a system starting in the same place (5, 5), with random fluctuations of the same amplitude, whose dynamics bear no relation to surprise. Not only does it enter more surprising regions of space; it also fails to achieve any sort of steady state, dissipating in an unconstrained fashion over time. The scope of Active Inference is restricted to systems like that on the left—which counter random fluctuations with their average flow and thereby retain their form over time.Parr, Pezzulo & Friston (2022), Active Inference, chapter 3, caption to figure 3.3, p. 48. The superscript refers to a note in the book.

The book is careful about how little this is. The self-organising ink is not alive and does not infer anything. It has the least that any persisting thing must have.

Figure 3.3 shows a very simple example of a system equipped with a random attractor. This is analogous to a thermostat, which (in cybernetic parlance) has a single set-point and cannot learn or plan.Parr, Pezzulo & Friston (2022), Active Inference, chapter 3, p. 49.

The mathematics

What is being computed

Each ink particle has a position x = (x1, x2) in the dish. The water jostles it at random. We write the jostling as dW, an increment of Brownian motion, and its strength as Γ.

Passive water · model: INK.step, mode 'passive' dx=2ΓdW,⟨|x−x0|2⟩=4Γt

The mean squared distance from the starting point grows in proportion to time. Nothing in the equation refers to where the particle is.

Surprisal (also called surprise) measures how unlikely a state is under a probability density: ℑ(x) = −ln p(x). Entropy is its average. For a system that visits states in proportion to a steady-state density p*, the average over the density equals the average over time along a path.

Entropy is average surprisal · textbook eq. 3.1 · model: INK.stats, INK.pathSurprisal H[p]=Ep[ℑ(x)]=−Ep[lnp(x)]

A Gaussian cloud whose variance is σ² along each axis has entropy ln(2πeσ²). In passive water σ² = σ0² + 2Γt, so the entropy rises without limit until the walls intervene.

Entropy of a spreading drop · model: INK.passiveTheory H=ln(2πeσ2),σ2=σ02+2Γt

The self-organising flow adds one term. The particle drifts along (Q − Γ)∇ℑ, where ℑ is the surprisal of the steady-state density p*. The part −Γ∇ℑ runs downhill towards likely states and undoes what the fluctuations do. The part Q∇ℑ, with Q antisymmetric, runs along the contours of surprisal and changes nothing about the density. It is called solenoidal flow.

Self-organising flow · model: INK.flow, INK.step, mode 'self' dx=(Q−Γ)∇ℑ(x)dt+2ΓdW,ℑ(x)=−lnp*(x) Q=q(0−110)

Two consequences can be checked on the ink. The spread of the cloud, its covariance, is that of p* whatever the values of Γ and q. And the mean turning of the flow about the centre, ⟨x ∧ f⟩ = ⟨x1f2 − x2f1⟩, an angular momentum per unit mass, equals 2q for any shape of steady state.

What the solenoidal flow changes, and what it does not · model: INK.stats Cov[x]=Covp*[x],⟨x∧f⟩=2q

With one basin, p* is Gaussian with covariance Σ and the flow is an Ornstein–Uhlenbeck process. The two-basin density is an equal mixture of two Gaussians, and the ring is p* ∝ exp(−(|x| − 5)² / 2·1.1²); their surprisal and its gradient are written in closed form in the model. The equations are stepped by the Euler–Maruyama method with a fixed step of 0.01.

One step further

A boundary

So far the ink has been one thing. To speak of a thing and its surroundings we need a boundary. In the free energy principle the boundary is statistical. A Markov blanket b separates internal states μ from external states η when, once b is known, μ and η tell us nothing more about each other.

Here is the smallest exact example: three numbers (η, b, μ) that follow the same kind of flow as the ink, with a Gaussian steady state. The matrix Π lists how strongly each pair is coupled. External and internal are not coupled directly, so Πημ = 0. Each touches only the blanket.

At zero the blanket holds. Move it to couple inside and outside directly.

Measured on 1,500 samples · exact

Correlation of η and μ
–
Partial correlation, given b
–
Slope of the synchronisation map
–
Markov blanket and synchronisation map · model: INK.blanket, INK.blanketExact p(η,μ|b)=p(η|b)p(μ|b)⇔Πημ=0 σ(μ(b))=η(b)

The left plot shows that η and μ are correlated although they never interact directly. The middle plot removes from each what the blanket explains; nothing is left to relate them. The right plot shows why this matters. For every value of the blanket there is a most likely internal state μ(b) and a most likely external state η(b), and one is a function of the other. Da Costa and colleagues call this function the synchronisation map σ. It is the sense in which internal states can be read as carrying beliefs about what lies outside.

A caution. This example is linear and Gaussian, where all of the above is exact. Whether, and in what sense, Markov blankets of this kind exist in nonlinear, sparsely coupled systems, and what follows when they do, is an active research question (Aguilera et al. 2022; Biehl et al. 2021).

In brief, a Markov blanket is the set of variables that mediate all (statistical) interactions between a system and its environment.Parr, Pezzulo & Friston (2022), Active Inference, chapter 3, p. 43.

Reading

Where this comes from

What is established

Particles in still water spread by diffusion, and their mean squared displacement grows in proportion to time (Einstein 1905). The entropy of a Gaussian density is the logarithm of its spread (Shannon 1948).

For a random dynamical system with a steady-state density, the flow can be written as (Q − Γ)∇ℑ, a part that descends the surprisal of that density and a solenoidal part that circulates on its contours (Friston & Ao 2012; Friston 2019; Parr, Da Costa & Friston 2020). The long-term average of surprise is entropy (textbook eq. 3.1).

In linear Gaussian systems conditional independence is a zero in the precision matrix, and the most likely internal state given the blanket is a function of the most likely external state (Da Costa et al. 2021).

The free energy principle is a principle and a modelling framework. This page illustrates part of it. It is not evidence for it.

What this model leaves out

There is no inference here and no free energy. The ink has no model of anything. Bounded entropy is the least a persisting thing must have, and a thermostat has it too. With q = 0 the self-organising ink is at equilibrium, like sediment settling in a bowl; only with q above zero is the steady state a nonequilibrium one.

We chose the steady state and wrote down the flow that has it. In a real system the steady state is a consequence of its dynamics. We also kept Γ and Q constant; in general both may vary with the state, which adds a further term to the flow.

The particles do not interact and the water does not move. Real ink in a dish is carried mostly by currents in the water; diffusion alone would be far slower. Units are arbitrary. The picture is a smoothed density of the simulated particles, drawn as pigment absorbing light.

The time step of 0.01 biases the steady-state spread by about one per cent at the largest q. The entropy estimate from bin counts is biased low by roughly (occupied bins − 1) / 2N (Paninski 2003). The walls reflect, which barely touches steady states that sit well inside the dish.