Skip to the essay
Conor HeinsNotes on collective intelligence

Collective computation as Bayesian inference
Moving beyond metaphors when we talk about collective intelligence

Read the paper: Collective Sensing as Emergent Bayesian Inference

Single fish adjust their speed according to the light level, and the school can collectively navigate to darkness. How does that happen?

  1. Light at each fish

  2. Differences in speed

  3. Direction + uncertainty

01The question

Where does the computation live?

In the months leading up to starting my PhD with Iain Couzin at the Max Planck Institute of Animal Behavior in Konstanz, I was reading papers from his group, and one in particular (by Andrew Berdahl and colleagues) really excited me; it seemed a fertile testing ground for some of the ideas around Bayesian descriptions of complex systems dynamics that had been floating around my head for years.

Berdahl and colleagues’ 2013 study of collective sensing in golden shiners combined experiments with a model of light-dependent movement. I found its proposed mechanism an inspiring demonstration of emergent computation: a school could respond to a light gradient even though the individual agents in the model had no gradient sensor.

Speed differences between fish changed their relative positions, and social interactions converted those differences into collective motion. Somewhere in that mesoscopic space between the individuals and the school, something like a representation of a gradient was taking shape.

In a Science podcast interview about the paper, Andrew Berdahl offered an analogy that made the mechanism click for me. Think of two fish coupled by social forces as two independently driven wheels on opposite ends of an axle. When one motor speeds up and the other slows down, the coupled system turns. In a sense, the system represents a vector, even though each motor can only accelerate or decelerate. If each motor’s speed responds to a local scalar field, such as light intensity, the pair starts carrying information about the local gradient by virtue of being separated in space.

It was this analogy that lit up my intuition and made me think it might be possible to connect that emergent computation to Bayesian inference.

This gave me a concrete system in which to test ideas about collective, or emergent, Bayesian mechanics. What environmental quantity was the school estimating? Where might a collective belief be expressed in its positions and speeds? Could the way those quantities changed through social interactions be described as an inference process? I wanted a formalism that could turn these questions into a testable mathematical account of the collective sensing mechanism.

The Bayesian side of this story had begun during my bachelor’s degree. Reading Andy Clark’s Whatever next? Predictive brains, situated agents, and the future of cognitive science had drawn me into the idea that brains, and more ambitiously all complex systems, were well described as inferential systems that are constantly moderating a predictive exchange between themselves and their environments. This seemed well captured by the notion of the Free Energy Principle. That interest helped set me on the path to Karl Friston’s group. Karl became my co-advisor during the PhD, so these questions developed alongside my work with Iain.

For me, this work represents a synthesis of the study of collective computation with the free energy principle; it serves as a worked example of how collective computations might be identified with Bayesian, active inference. Iain’s work offered concrete examples of collective computation emerging from local interactions; Karl’s offered a mathematical language for asking how physical dynamics might be understood as inference. I wanted to bring those perspectives together, so that calling a group “intelligent” could lead to a precise, testable account of what it computes and how.

My paper, Collective Sensing as Emergent Bayesian Inference, accepted at IWAI 2026, is a step in that direction. This essay lets you explore the mechanism, the proposed description, and the questions that remain.

02The mechanism

Local rules.
A collective sense of direction.

Imagine looking for shade with a sensor that only tells you how bright it is here. Add neighbors with the same limitation. What changes?

LIGHTSHADE

Feel the light.

A fish swims faster in bright water and slows down in shade. It receives one local light value, with no gradient sensor telling it which way to turn. Moving slowly can make it spend longer in shade without estimating a direction.

LIGHTSHADE

Respond to neighbors.

Fish avoid very close neighbors, align with nearby headings, and move toward more distant neighbors. Each fish’s social response depends on that changing geometry.

LIGHTSHADE

Turn differences into direction.

These interactions provide a physical route from variation in light to collective turning. Directional information becomes available in the relationships among fish. The coral arrow here is schematic; the live estimate appears below.

03The living model

Change the rules.
Watch the school.

Start with one fish, bring in its neighbors, then reveal the collective estimate. Drag the shade to move it. Pause or advance one step for a closer look.

An experiment you can change Open full simulation
Try this

Choose an experiment above, then change one thing at a time. Pause whenever you want to look more closely.

Go to the simulation
Drag the shade, change the school size, or reveal the estimate. The fish follow local rules; the estimate never steers them. The simulation pauses when it leaves view.

This is an educational adaptation. Gentle motion makes turns easier to follow, but changes the trajectories. A single run cannot establish that larger groups perform better on average.

04The Bayesian description

From movement to a belief.

Light changes swimming speeds. Speed differences reshape the school. Can these changing relationships express a collective belief about the light gradient?

Collective belief / Gradient direction

A small school in a green darkness field, with a direction graph overlaid at its center. A coral posterior-mean arrow and shaded envelope show the belief about gradient direction; a dashed green arrow points toward darker water.
A schematic collective belief overlaid on a school, with the direction axes anchored at its center. Green shading shows the darkness field; the coral envelope shows uncertainty about its direction, with stronger coral shading for more probable directions.

Slower fish on one side are evidence for darker water on that side. Positions give the speed differences a direction. These relationships also shape what the school does next: different speeds change its geometry, and social interactions turn that changing geometry into collective motion. The proposed Bayesian description locates a collective belief in these evolving relationships.

To make this precise, approximate the local darkness field as a tilted plane. Its unknown tilt is the gradient. After subtracting local mean position and speed, the remaining differences constrain which gradients are compatible with the school. Speed decreases as darkness increases, so the spatial pattern of speeds provides evidence about the direction of increasing darkness.

In this browser model, evidence from four moving local neighborhoods combines with a weak prior to give a distribution over possible gradients. As the fish move and their relationships change, so does this collective belief. Its mean gives the coral arrow. The shaded envelope shows the posterior probability density over direction: stronger shading marks more probable directions, and a broader spread means less directional certainty. The simulation’s small gradient plot also shows magnitude and its uncertainty. The true gradient is calculated separately for comparison.

Results

Three tests of the mechanism and its Bayesian description.

Interactions improve collective sensing.

With alignment and attraction, larger schools generally experience more darkness. This improvement in sensing performance with group size is the central evidence for collective sensing in Berdahl and colleagues’ original study. Removing those interactions gives a much flatter curve, even though fish still slow down in shade and avoid collisions. The relationships between fish make a difference to where the school ends up.

A darkness-exposure ratio above 1 means greater darkness exposure than the independent-field reference.

Adapted from Figure 3d. Means ± standard errors across 64 simulation seeds per school size. “Coupling off” removes alignment and attraction; repulsion and the response to light remain.

The speed–position relationship carries the direction.

Keep the same trajectories, but reassign swimming speeds among fish within local groups or spatial windows before calculating the posterior. Directional agreement collapses. The distribution of speeds alone is not enough: which speed belongs to which position matters.

Directional cosine is 1 for perfect agreement with the true gradient, 0 for no net directional agreement, and −1 for the opposite direction.

Adapted from Figure 12b · Appendix J. Means and 95% seed-bootstrap intervals across 16 simulations of 64 fish. Each shuffled condition averages eight repetitions per seed. This changes the evidence used to calculate the posterior, not the swimming trajectories.

The posterior can be too certain.

A Bayesian description gives us uncertainty to test as well as a mean direction. Here, the local posteriors for larger schools tend to be narrower than their errors warrant. Capturing directional information does not automatically mean that the model has captured how reliable that information is.

The ratio compares squared gradient error with the total posterior variance. Above 1 indicates overconfidence; 1 is the nominal target under the working model.

Adapted from Figure 3a. Pooled means over active local neighborhoods and frames, from 16 simulation seeds per school size. Reference and estimated gradients use the same arena units. The published summary does not provide error bars.

Why does the school’s shape matter?

Two fish separated along a line can constrain how darkness changes along that line, while leaving the perpendicular direction poorly determined. A group spread across two dimensions has a different sampling geometry. These differences shape the posterior, including how tightly its probability is concentrated around particular directions.

How much should we trust the uncertainty?

Neighboring fish sample a spatially correlated environment. The likelihood includes a spatial covariance model, with correlation length tied to the group’s spread, and estimates a residual noise scale from the observations.

Overlapping neighborhoods reuse fish, and a curved field may not have one shared gradient across the school. The envelope shows directional probability density under this working model; it is not a 95% confidence cone. The ellipse in the simulation’s small gradient plot is a nominal 95% region for the full gradient, without a demonstrated coverage guarantee. The paper’s calibration analyses find overconfidence, including substantial overconfidence at the school level.

Is there a central controller telling the fish where to go?

The school moves through local interactions. No fish explicitly runs Bayes’ rule or receives the coral arrow as a steering command. Showing the collective belief adds no controller, and the true gradient used for comparison does not enter the estimate.

The hypothesis is that the dynamics of these relationships can be understood as approximate inference. Giving them a Bayesian description makes that correspondence testable; it does not, by itself, establish it.

05The open question

A description we can put to the test.

This returns me to the motivation for the work: how can we give computation through interactions a precise mathematical description?

At an intermediate, or mesoscopic, scale, the collective can be described using a distribution over an environmental quantity. That gives us an identifiable target, a likelihood, uncertainty, and predictions to check. It makes “the school senses a gradient” a more specific claim.

The paper compares estimates with the simulated field, examines uncertainty against error, and disrupts local speed–position relationships. Shuffling speeds within local groups damages directional accuracy. A fitted heading model also connects the inferred gradient and heading persistence to subsequent collective movement.

Details on the visual simulation and how it differs from what’s in the paper

The scene begins with a stationary, smooth dark feature. Optional background variation uses a small set of smooth waves instead of the paper’s stochastic field process. The simulation combines current-frame evidence without the paper’s temporal replay filter or fitted heading model.

The default Gentle preset lowers the maximum turn angle. That changes trajectories and potentially sensing performance; slowing playback only changes how quickly you watch them. Original restores the original turning cap, but does not make the whole explorable a reproduction of the paper’s experiments. Neither preset adds physical inertia.

Turn Response to light to zero to remove speed differences due to local darkness. Switch off Social interactions to disable attraction and alignment; short-range repulsion remains. These interventions separate ingredients of the mechanism. Reliable comparisons of performance require repeated trials.

Start with the fish.
Look for the relationships.

Back to the simulation