Six fish swim in two schools of three. Each fish is an active inference agent — it minimises variational free energy through perception (sensing the flow field via its lateral line) and action (generating thrust via tail-beats that shed vortices into the water).
The fish do not follow pre-programmed flocking rules. Their coordinated behaviour emerges from three nested levels of precision-weighted coupling — the same mechanism operating at different spatial scales.
Level 1 — Individual blanket. Each fish maintains a statistical boundary between its internal states (body oscillators) and the external world (water flow). The dashed line around each fish represents this boundary. The fish's sensory states are its lateral line receptors; its active states are its tail-beat thrust vectors.
Level 2 — Group blanket. Within each school, pairs of fish accumulate evidence of mutual predictability — generalised synchrony. When fish can predict each other's movements, a group-level Markov blanket emerges (the larger dashed boundary around each school). The school now behaves as a single higher-order agent.
Level 3 — Collective blanket. When the two schools interact strongly enough, an even larger blanket can form around the entire collective. This appears as the purple dashed boundary when the boundary between schools becomes sufficiently permeable (low Πbetween-groups).
Πindividual controls the precision of each fish's internal oscillators — how tightly its body dynamics are tuned. High precision means slow, stereotyped tail-beats: the fish repeats the same motor pattern precisely. Low precision means loose, variable oscillators producing fast, irregular swimming. Note: this is oscillator precision (the tightness of internal dynamics), distinct from the policy precision (γ) that governs the exploration–exploitation trade-off in Chapter 7 of the textbook.
Πwithin-group controls each fish's individual blanket rigidity within its school. High precision means each fish strongly maintains its own boundary, resisting social influence — the school dissolves into independent swimmers. Low precision means permeable individual blankets, allowing generalised synchrony to build — the school self-organises as a higher-order agent.
Πbetween-groups controls how strongly each school maintains its boundary against the other. High precision means autonomous, separate schools. Lower precision allows cross-group coupling — push this low enough and the two schools merge into a single collective agent with a shared generative model.
Prediction error drive controls the strength of proprioceptive predictions that generate action via classical reflex arcs (Ch.5). Higher drive means stronger descending motor predictions, producing more vigorous thrust and larger vortices shed into the water. This is the amplitude of active inference — how forcefully the fish acts on its beliefs — not the direction of action selection.
1. Set Πbetween-groups to maximum (slider right). The two schools maintain strong, separate boundaries — two autonomous agents with independent generative models.
2. Slowly lower Πbetween-groups (slide left). Watch generalised synchrony build between the schools. When blanket permeability is high enough, a collective Markov blanket emerges (the purple dashed boundary) — a single higher-order agent.
3. Now raise Πindividual to maximum (slider right). Each fish's oscillators become tight and precise — slow, stereotyped tail-beats. This is exploitation: repeating known patterns.
4. Lower Πindividual to minimum (slider left). Fish become fast and wriggly — loose oscillators producing high-variance motor output. Notice that the group blanket may weaken because rapid, irregular movement makes mutual predictability harder to sustain.
Each fish minimises variational free energy through two complementary channels: perception (updating internal beliefs about the flow field based on lateral line input) and action (generating thrust to change the sensory input it receives).
When fish coordinate successfully, the collective surprise is lower than any individual could achieve alone — this is why schools form.
The coupling strength between pairs of fish is not a fixed parameter. It is precision-weighted — it grows exponentially as the pair accumulates evidence of mutual predictability. This is the key mechanism: prediction errors between aligned fish are weighted by higher precision, creating stronger coupling.
When two active inference agents share similar generative models and can sense each other, their internal states converge onto a synchronisation manifold. The pair-link indicators in the left panel show this process in real time — the progress bar fills as evidence accumulates, then resets at a synchronisation event.
The three Π sliders correspond to three levels of a hierarchical generative model. Higher levels change more slowly and contextualise faster dynamics below. The school-level blanket contextualises individual swimming; the collective blanket contextualises school-level dynamics.
When a collective of agents maintains a group-level Markov blanket, the group itself can be described as an active inference agent with its own generative model. The group-level parameters are not simply averages of individual parameters — they have a non-trivial emergent relationship.
In the textbook (Ch.7), the exploration–exploitation trade-off is governed by precision on policies (γ): the inverse temperature in the softmax π₀ = σ(−γG). High γ → peaked policy selection → exploitation. Low γ → flat policy selection → exploration. Both epistemic value (information gain) and pragmatic value (preference satisfaction) are components of the same expected free energy — Active Inference dissolves the exploration–exploitation dilemma by optimising both simultaneously.
The Πindividual slider in this simulation controls a different level: oscillator precision — how tightly each fish's internal dynamics are tuned. High oscillator precision produces slow, stereotyped tail-beats (exploiting a known motor pattern). Low oscillator precision produces fast, variable swimming (noisier motor output, not confident exploration). The vigorous movement at low precision reflects higher variance in motor dynamics, not a deliberate search strategy.
Parr, T., Pezzulo, G., & Friston, K. J. (2022). Active Inference: The Free Energy Principle in Mind, Brain, and Behavior. MIT Press. Open access.
Palacios, E. R., Razi, A., Parr, T., Kirchhoff, M., & Friston, K. (2020). On Markov blankets and hierarchical self-organisation. Journal of Theoretical Biology, 486, 110089.
Kirchhoff, M., Parr, T., Palacios, E., Friston, K., & Kiverstein, J. (2018). The Markov blankets of life: autonomy, active inference and the free energy principle. Journal of the Royal Society Interface, 15(138), 20170792.
Thestrup Waade, P., Lundbak Olesen, C., Ehrenreich Laursen, J., Nehrer, S. W., Heins, C., Friston, K., & Mathys, C. (2025). As One and Many: Relating Individual and Emergent Group-Level Generative Models in Active Inference. Entropy, 27(2), 143.
Friston, K., & Frith, C. D. (2015). A Duet for one. Consciousness and Cognition, 36, 390–405.
Friston, K., & Frith, C. D. (2015). Active inference, communication and hermeneutics. Cortex, 68, 129–143.
Friston, K., et al. (2020). Generative models, linguistic communication and active inference. Neuroscience & Biobehavioral Reviews, 118, 42–64.
Palacios, E. R., Isomura, T., Parr, T., & Friston, K. (2019). The emergence of synchrony in networks of mutually inferring neurons. Scientific Reports, 9, 6412.
Parr, T., et al. (2021). Markov blankets in the brain. Neuroscience & Biobehavioral Reviews.
This simulation was developed by Alexander Sabine (Active Inference Institute, Board of Directors) for pedagogical purposes. Interactive demonstrations at temporalgrammar.ai.
Contact: Alexander@activeinference.institute