Chapters 1 and 3BeginnerNew
Of woodlice and shade
Woodlice gather in damp shade. They do not want to, they do not know where it is, and they do not steer towards it. They move faster where it is hot and dry, and slower where it is cool and damp. From that one rule a shape appears: a crowd in the shade. Things that last are found, most of the time, in the states that keep them going. The free energy principle starts from that observation.
Drag a thing to move it. With the keyboard: choose a thing with its button, click the picture or tab to it, then use the arrow keys to move the thing, R to turn it and W to pour water on it. With the watering can chosen, a click or tap on the ground pours there. You cannot pick up a woodlouse.
Learn by doing
Try this
- Move the shade. Predict what the crowd under the bark will do when the bark is carried to the other side. It does not follow. The animals left in the sun speed up at once, scatter, and gather again only when chance takes them under the bark's new position.
- Take the rule away. With a thousand walkers on the stage, predict the shape of the crowd when speed is the same everywhere. The map goes flat, and the entropy rises to its largest possible value, ln 1000 = 6.91 nats.
- Take the shade away. Water reserves are on. Predict how long the woodlice last on bare paving at midday, then lift the cover and count. Put it back, pour water under it, and watch the survivors' rings refill.
- Blur its senses. Give the woodlice antennae and precise senses, and nearly all reach the shade and stay. Now lower the precision to 1. Predict whether steering still helps when the two antennae disagree by chance more than by cause.
- Make a damp place, and watch the entropy fall. On bare paving the entropy is at its maximum. Put down one piece of bark and read H again. Then pour a can of water under the bark and read it a third time. Each thing you add gives the crowd more shape.
- Protect them. Five days, each harder than the last. Doing nothing loses every animal on every day. A careful gardener can save most of them.
Where the idea goes next
A shape that keeps itself
Karl Friston has said that he first came up with a prototype of the free energy principle at the age of eight, in a garden, in a hot British summer of the 1960s, watching woodlice (Friston, Fortier & Friedman 2018). After half an hour, he says, he saw what they were doing:
I realized their “scurrying” had no purpose or intent: they were simply moving faster in the sun—and slower in the shade.Karl Friston, in Friston, Fortier & Friedman (2018), ALIUS Bulletin 2, p. 17
What the woodlice do is not inference in any rich sense. They hold no map, weigh no evidence and plan nothing. The rule is the simplest thing there is that keeps a creature among the states it can survive in, and that is why Friston calls it a prototype of the principle and not an example of its full machinery. The free energy principle generalises the same observation. Anything that lasts must, on average, be found in a small set of states, so the surprisal of its states must stay low. A creature cannot measure its own surprisal, but it can measure something that is never smaller: its free energy, the mismatch between what it senses and what its model of the world expects. Keeping that small, by changing its beliefs and by acting, is what the rest of this site is about.
The mathematics
What is being computed
Lengths are in centimetres and the patch is 40 by 25 cm. Logarithms are natural, so information is in nats. The numbers under each equation are read from the model as it runs on the stage.
The walker runs in a straight line at speed v(x), which depends only on where it is, and now and then it takes a new heading at random (a "run and tumble"; rate λ, here 0.3 per second). y(x) is what it senses there: a number from 0 (dark and damp) to 1 (bright or dry), built from the light, the temperature and the humidity of the ground. p*(x) is the steady-state density: the share of an ensemble of such walkers found in each square centimetre once the picture has stopped changing. The reason for 1/v is short. Write the density of walkers at x with heading θ as p(x, θ). The number crossing any small line per second is v p. If p = c/v for every heading, that number is the same constant c in every direction at every place, so as many arrive as leave, everywhere. Turning at random changes nothing, because the headings are already evenly spread. So the tumbling rate λ does not appear in p* at all, even if it differs from place to place: turning more often in one spot does not gather walkers there. It changes only how quickly the shape is reached. The result is standard in the physics of run-and-tumble particles (Schnitzer 1993; Tailleur & Cates 2008). Code: WL.steadyState, WL.stepEnsemble. The tests compare measured occupancy with 1/v on four speed landscapes and in this garden, with even and with uneven tumbling.
ℑ is the surprisal of being at x. H, the entropy, is its average over the ensemble. The last equality says that the average along one walker's path, taken for long enough, is the same number; it holds because one walker in time visits places in the same proportions as many walkers at one moment. With p* per square centimetre, H cannot exceed ln(40 × 25) = 6.91 nats, the value for a crowd spread evenly. The walker's long-run average under the equation is computed by following one walker through the present garden for 24 hours of its time. Code: WL.followOne.
w is the water reserve, from 1 (full) to 0 (dried out). D is the saturation deficit of the air at the ground: how much more water vapour it could hold, which is the relative humidity h short of 1, times the saturation vapour pressure es at temperature T (the Tetens formula). Edney (1951) found that woodlice lose water roughly in proportion to it. n is the number of other woodlice touching this one. The rate k, the gain g on damp ground, and the saving s are settings: the day is compressed into a minute and a half, and the drying is speeded to match. Because one animal's path samples the garden as p* does, its long-run rate of loss is k times the p*-average of D. Code: WL.stepAnimals, WL.computeFields.
μ is the animal's estimate of how bright and dry it is where it stands. η = 0 is what it expects beforehand, damp and dark, held with precision Πμ = 1; in active inference a preference is written as a prior of this kind. y is what it senses, with precision Πy. εy and εμ are the two prediction errors, and F is the free energy of the estimate. Perception moves μ down the slope of F and comes to rest at μ*, the precision-weighted average of sensation and prior, which for this linear model is the exact posterior mean (tested). At rest the two weighted errors are equal: Πyεy = Πμεμ = ξ. The values shown are for the marked woodlouse. Code: WL.freeEnergy, WL.posteriorMean.
In this notation action follows ȧ = −κa (∂y/∂a) Πyεy: it can lower F only by changing what is sensed. For a woodlouse whose only action is its speed, and which cannot tell which way the damp lies, ∂y/∂a at any instant is as likely to be positive as negative, so that rule gives nothing on average. What speed does change is how long the animal stays. By the first equation, the long-run average of its free energy is F̄ above, and differentiating p* = (1/v)/Z gives the gradient shown. It is negative wherever F is above its own average: go faster there, and F̄ falls. It is positive wherever F is below average: go slower there. That is orthokinesis. The gradient formula is exact and is tested against a finite difference and against a simulation. Two steps are interpretation and not theorem. The first is to take the long-run average F̄, and not F at each instant, as the thing action descends; this follows the principle's own statement in terms of the long-run average of surprise. The second is the shape of the response. The true minimum of F̄ with a limited top speed is all-or-nothing; the page uses the straight line v = vslow + (vfast − vslow) ξ/Πμ, clipped, so that speed is in proportion to the precision-weighted error. Code: WL.dFbar, WL.worldFbar.
θ is the heading. Two sensors, to the left and right of the head, give two estimates μL and μR. Now a change of heading does change what is sensed, and the difference between the sensors estimates by how much, so ȧ = −κa (∂y/∂a) Πyεy can be used as it stands: turn away from the drier side, harder when the error ξ is large. With this term the 1/v law no longer describes the crowd, which is denser in the shade than 1/v allows. Each sensor carries noise of variance 1/Πy. When Πy is low the two estimates differ mostly by chance and the animal is steered by noise. Code: WL.stepAnimals.
In other words, had my woodlice just been basking in the sun—making exquisite Bayesian inferences about their inexorable desiccation—there would have been no self-organization (and nothing of note to witness).Karl Friston, in Friston, Fortier & Friedman (2018), ALIUS Bulletin 2, p. 22
Reading
Where this comes from
What is established
Woodlice are more active in dry air and come to rest in damp air; Gunn (1937) measured this in Porcellio scaber, and Fraenkel & Gunn (1940) named responses of this kind kineses and set them apart from taxes, in which the animal steers. Woodlice lose water through the cuticle at a rate that follows the dryness of the air (Edney 1951, 1968) and can take it up again from damp surfaces (Spencer & Edney 1954). They slow and gather on contact (Devigne, Broly & Deneubourg 2011), and animals in groups lose water more slowly (Allee 1926; Broly, Deneubourg & Devigne 2013; Broly et al. 2014). Pill woodlice roll into a ball, which also saves water (Smigel & Gibbs 2008). Woodlice are active mainly at night (Cloudsley-Thompson 1952).
That walkers whose speed depends on place gather in proportion to 1/v, whatever their turning rate, is a standard result for run-and-tumble particles (Schnitzer 1993; Tailleur & Cates 2008; Cates & Tailleur 2015). That the long-run average of surprisal is an entropy, and that a system which persists keeps that entropy bounded, is the starting point of the free energy principle (Friston 2010, 2013; Parr, Pezzulo & Friston 2022, chapter 3).
The free energy principle is a principle and a way of building models. This page illustrates it; it is not evidence for it.
What this model leaves out
Real woodlice do more than this. They turn away from light, follow edges and squeeze into crevices, change their response to humidity with the time of day and with how dry they are, and keep a rhythm of their own. None of that is here. The rule that speed is a straight-line function of one mixed signal of light and dryness is a simplification made for this page; it is not a law that Gunn measured.
The microclimate is a sketch: the amounts by which sun heats the ground, cover and water raise humidity, and air mixes are settings chosen to be reasonable, not measurements. So are the rates of drying and drinking, which are speeded up so that a day fits into a minute and a half. The edge of the picture acts as a wall. The twenty animals on the stage avoid walking through each other; the thousand walkers of the ensemble do not, and the tests of the 1/v law use the ensemble.
The inference in step 6 is the smallest that can be written: one number believed, one number sensed, both Gaussian. Nothing is learned and nothing is planned. Reading the kinesis as a descent on the long-run average of free energy is an interpretation, set out with its two assumptions in the mathematics above. The night baseline of activity in day 5 is a setting. There is no heat shimmer and no sound. The woodlice are drawn about a third larger than life.
- Friston, K., Fortier, M. & Friedman, D. A. (2018). Of woodlice and men: A Bayesian account of cognition, life and consciousness. An interview with Karl Friston. ALIUS Bulletin, 2, 17–43. doi:10.34700/h460-nz89
- Parr, T., Pezzulo, G. & Friston, K. J. (2022). Active Inference: The Free Energy Principle in Mind, Brain, and Behavior. MIT Press. Chapter 3, equation 3.1. doi:10.7551/mitpress/12441.001.0001
- Friston, K. (2010). The free-energy principle: a unified brain theory? Nature Reviews Neuroscience, 11, 127–138. doi:10.1038/nrn2787
- Friston, K. (2013). Life as we know it. Journal of the Royal Society Interface, 10, 20130475. doi:10.1098/rsif.2013.0475
- Bogacz, R. (2017). A tutorial on the free-energy framework for modelling perception and learning. Journal of Mathematical Psychology, 76, 198–211. doi:10.1016/j.jmp.2015.11.003
- Buckley, C. L., Kim, C. S., McGregor, S. & Seth, A. K. (2017). The free energy principle for action and perception: A mathematical review. Journal of Mathematical Psychology, 81, 55–79. doi:10.1016/j.jmp.2017.09.004
- Gunn, D. L. (1937). The humidity reactions of the wood-louse, Porcellio scaber (Latreille). Journal of Experimental Biology, 14, 178–186. doi:10.1242/jeb.14.2.178
- Fraenkel, G. S. & Gunn, D. L. (1940). The Orientation of Animals: Kineses, Taxes and Compass Reactions. Oxford: Clarendon Press.
- Edney, E. B. (1951). The evaporation of water from woodlice and the millipede Glomeris. Journal of Experimental Biology, 28, 91–115. doi:10.1242/jeb.28.1.91
- Edney, E. B. (1968). Transition from water to land in isopod crustaceans. American Zoologist, 8, 309–326. doi:10.1093/icb/8.3.309
- Spencer, J. O. & Edney, E. B. (1954). The absorption of water by woodlice. Journal of Experimental Biology, 31, 491–496. doi:10.1242/jeb.31.4.491
- Cloudsley-Thompson, J. L. (1952). Studies in diurnal rhythms. II. Journal of Experimental Biology, 29, 295–303. doi:10.1242/jeb.29.2.295
- Allee, W. C. (1926). Studies in animal aggregations: causes and effects of bunching in land isopods. Journal of Experimental Zoology, 45, 255–277. doi:10.1002/jez.1400450108
- Devigne, C., Broly, P. & Deneubourg, J.-L. (2011). Individual preferences and social interactions determine the aggregation of woodlice. PLoS ONE, 6, e17389. doi:10.1371/journal.pone.0017389
- Broly, P., Deneubourg, J.-L. & Devigne, C. (2013). Benefits of aggregation in woodlice: a factor in the terrestrialization process? Insectes Sociaux, 60, 419–435. doi:10.1007/s00040-013-0313-7
- Broly, P., Devigne, L., Deneubourg, J.-L. & Devigne, C. (2014). Effects of group size on aggregation against desiccation in woodlice (Isopoda: Oniscidea). Physiological Entomology, 39, 165–171. doi:10.1111/phen.12060
- Smigel, J. T. & Gibbs, A. G. (2008). Conglobation in the pill bug, Armadillidium vulgare, as a water conservation mechanism. Journal of Insect Science, 8, 44. doi:10.1673/031.008.4401
- Schnitzer, M. J. (1993). Theory of continuum random walks and application to chemotaxis. Physical Review E, 48, 2553–2568. doi:10.1103/PhysRevE.48.2553
- Tailleur, J. & Cates, M. E. (2008). Statistical mechanics of interacting run-and-tumble bacteria. Physical Review Letters, 100, 218103. doi:10.1103/PhysRevLett.100.218103
- Cates, M. E. & Tailleur, J. (2015). Motility-induced phase separation. Annual Review of Condensed Matter Physics, 6, 219–244. doi:10.1146/annurev-conmatphys-031214-014710