Active Inference InstituteSimulations

Chapter 8IntermediateNew edition

Agents that model one another fall into step

Each disc is an agent with its own rhythm. It predicts that what it senses from its neighbours will match its own phase, and it moves to reduce the error. Raise the precision the agents afford one another, and past a critical value a shared rhythm appears.

Half-width of the Cauchy distribution, in rad/s.
Every link is simulated and drawn.
The theory curve stays hidden until you commit.
Draw or cut a link: tap two agents on the stage, or choose agents and

Learn by doing

Try this

  1. Find the threshold. The agents start with almost no precision for one another, and each keeps its own rhythm. Before you touch K, move the gold marker to the coupling at which you expect a shared rhythm to appear, and commit. Then raise K slowly and watch the green point on the chart. The theory curve appears once you have committed.
  2. Widen the spread. The agents are in step. Predict what happens if their natural frequencies become more varied, then drag Δ upwards. The threshold moves with it, and the shared rhythm dissolves when it passes K.
  3. A duet. Two agents, each predicting the other. Their natural frequencies differ by 2Δ. Predict how much coupling they need to lock, then raise K. Watch the red arcs, which are the prediction errors, shrink to a fixed lag.
  4. Deafen one singer. The pair is locked at the mean of their frequencies. Predict who will follow whom when agent 1 stops listening. Then deafen it. Agent 1 returns to its own rhythm; agent 2 still follows, further behind.
  5. Two communities. Each community is coherent, but the bridges between them carry no precision, so the two drift past each other. Predict what the phase-locking matrix will look like when they merge. Raise the bridge precision and watch the off-diagonal blocks fill in.
  6. Cut the bridges, then restore them. The communities are merged. Cut the bridges and the shared rhythm breaks into two. Restore them and it re-forms. Watch the two information read-outs: what one interior tells you about the other, with and without knowing the linking agents.

The mathematics

What is being computed

Each agent i has one internal state, a phase θi. It is the agent's expectation about the phase of the rhythm it takes part in, and also the phase of the signal it emits. The agent senses the phases θj of its neighbours. This is a deliberately minimal reading of the duet papers of Friston and Frith (2015), in which each bird has a rich, hierarchical generative model of song. Here the generative model is one line.

1 · Generative model and free energy p(θj|θi)∝exp[κijcos(θj−θi)] Fi=∑jκij[1−cos(θj−θi)]

Agent i expects the signal from j to share its own phase, with a von Mises density (the circular counterpart of a Gaussian) of precision κij. Precision is the confidence placed in a prediction. With a point belief at θi, the free energy Fi is the negative log probability of what the agent senses. It is written here in nats above its minimum, so it is zero when every neighbour is exactly in phase.

2 · Each agent descends its own free energy θ˙i=ωi−∂Fi∂θi=ωi+∑jκijsin(θj−θi)

ωi is the agent's natural frequency: its prior belief about how fast its own phase advances. The second term is a sum of prediction errors, sin(θj − θi), each weighted by its precision. This is the textbook's gradient flow for continuous states, with the expected motion ωi in place of Dμ.

3 · With equal precisions this is the Kuramoto model κij=KN:θ˙i=ωi+Krsin(ψ−θi),reiψ=1N∑jeiθj Kc=2Δ,r=1−Kc/Kfor K>Kc

The order parameter r, between 0 and 1, measures how closely the phases agree, and ψ is their mean phase. Each agent is pulled towards ψ with a strength that grows with r, so agreement breeds agreement. For natural frequencies drawn from a Cauchy distribution of half-width Δ and very many agents, Kuramoto's result is exact: no shared rhythm below Kc, and the curve above it. The white vector in the polar plot is r eiψ.

4 · Two agents φ=θ1−θ2:φ˙=(ω1−ω2)−(κ12+κ21)sinφ locked when |ω1−ω2|≤κ12+κ21,sinφ*=ω1−ω2κ12+κ21,Ω=κ21ω1+κ12ω2κ12+κ21

κ12 is the precision agent 1 gives to what it hears from agent 2. With κ12 = κ21 = K/2 the pair locks when K ≥ |ω1 − ω2|, at the mean of the two frequencies. Deafening agent 1 sets κ12 = 0: the shared frequency Ω becomes ω1, so agent 1 leads, and the lag grows to asin(2(ω1 − ω2)/K).

5 · What one community tells you about the other I(a;b)=ln2π−H[a−b],I(a;b|z)≈−12ln(1−ρ2)

a and b are the mean phases of the interior agents of communities A and B: those with no link to the other side. z stands for the phases of the linking agents. The first quantity is the mutual information between the interiors, estimated from a histogram of a − b; H is differential entropy. The second is the information that remains once the linking agents are known, a Gaussian estimate from the partial correlation ρ of a and b after regression on z. It is meaningful while each community is coherent. Both are in nats, over the most recent samples.

Two further measures are drawn on the stage. The phase-locking value of a pair is |⟨ei(θi − θj)⟩|, averaged over about the last 20 seconds (Lachaux et al. 1999). When every natural frequency is equal and precisions are symmetric, the total free energy ΣFi can only fall: set Δ to zero to see it.

Reading

Where this comes from

When what is out there is another creature with a similar model, this synchronization means the internal states of one creature should come to resemble the internal states of the other: a primitive kind of theory of mind.Parr, Pezzulo & Friston (2022), Active Inference, chapter 8, section 8.4, pp. 162–163

What is established

Friston and Frith (2015) simulated two songbirds with the same generative model, each predicting the sensations the other causes. The two come to generalised synchrony: the internal states of one track those of the other. They propose this as a minimal account of communication. Palacios and colleagues (2019) found that synchrony emerges in networks of model neurons that each infer the others.

The mathematics of the transition is older and independent of active inference. Kuramoto (1975, 1984) solved the all-to-all model shown here, and Strogatz (2000) reviews it. The threshold Kc = 2Δ and the curve √(1 − Kc/K) are exact for Cauchy-distributed frequencies and infinitely many agents.

Under the free energy principle, a group whose members are coupled in this way is a candidate system at a higher level, with a boundary of its own: a Markov blanket, a set of states that separates inside from outside (Kirchhoff et al. 2018; Palacios et al. 2020). In the two-community graph, the agents that hold the bridges play that part. In this model, with symmetric precisions and noise, the density near a locked state factorises over the links of the graph, so the two interiors are conditionally independent given the linking agents. The estimate in panel two measures this.

What this model leaves out

Reading the Kuramoto model as free-energy descent is this page's simplification, not a result of the cited papers. In the duet papers each bird has a hierarchical model with chaotic dynamics, infers hidden causes over time, and takes turns by attenuating the precision of its own sensations while it sings. Here each agent has one phase, a point belief with no uncertainty, and fixed precisions. Agents sense phases directly and without noise, and nothing is learned.

The chart compares a finite network with a result for infinitely many agents. With few agents r does not fall to zero below threshold: it hovers near the chance level drawn on the chart. The Cauchy distribution has heavy tails, so a few agents are much faster or slower than the rest and never join.

The conditional independence shown for two communities depends on symmetric precisions and on being near a locked state. Whether Markov blankets can be read off sparse coupling in general is an open question (Biehl et al. 2021; Aguilera et al. 2022). The information estimates are short-window estimates, and the conditional one is a Gaussian approximation.

The free energy principle is a modelling framework. This page illustrates it; it is not evidence for it, and it makes no claim about how brains or birds synchronise.