A belief update and a generation of natural selection are the same calculation.
That is the starting point of "Bayes and Darwin" (Czégel, Giaffar, Tenenbaum and Szathmáry, BioEssays, 2022). The paper then asks how far the match goes. This page walks through each step with something you can run.
A forecaster's beliefs
A pond of microbes
The forecaster multiplies each belief by how strongly that hypothesis predicted what was seen, then rescales so the beliefs sum to one. The pond multiplies each strain's share by its reproductive success this year, and the shares again sum to one. The paper's wording is that every heritable variant is a hypothesis about how to live in the environment, and bad genes lose frequency the way bad hypotheses lose probability.
One update, worked through
Here is the arithmetic behind the panels above, using the same state. In this toy world a "dry specialist" does well in 80% of dry years and 20% of wet ones, the "wet specialist" is the reverse, and the generalist sits at 50% either way. Read as hypotheses, they claim that rain falls in 20%, 80% or 50% of years.
Applied year after year, the rule chains itself: today's prior is yesterday's posterior, just as this generation's frequencies are the output of the last round of selection. Nothing in either system stores the history. The current distribution is the memory.
The paper notes that the same match holds for continuous traits and continuous parameters, for example a Gaussian belief updated by Gaussian evidence, or a body-size distribution shifting under selection. That link has been studied less.
The dictionary
Each row is one mathematical object with two names. The switch in the top bar relabels every demo on this page with one column or the other. Dotted-underlined words in the text follow the switch too.
| Bayesian learning | Evolution | Symbol |
|---|---|---|
| Hypothesis | Type (strain, genotype, strategy) | hi |
| Data observed at time t | Environment at time t | xt |
| Prior probability | Relative frequency this generation | P(hi), pi(t) |
| Likelihood of the data under h | Fitness of type i in environment x | P(x | hi), fi(x) |
| Evidence (the normalizer) | Mean fitness of the population | Σ fi pi |
| Posterior probability | Relative frequency next generation | pi(t+1) |
| Transition probability between hidden states | Mutation probability between types | P(hi | hj), μi←j |
| Filtering in a hidden Markov model | Replicator-mutator dynamics | |
| Higher-level hidden variable | Collective (cell, colony, group) | zj |
| Inference in a hierarchical model | Multilevel selection | |
| Learning the structure of the model | Transition in individuality | |
| Particle | Individual | |
| Computing weights, then resampling | Selection, then replication | |
| Particle filter | Wright-Fisher model |
Both sides rest on one assumption the paper takes as given: each comes with a score for every possible , including ones that have never occurred. How organisms or models come to have such a function is a separate question.
Mutation as prediction: the most sophisticated parallel
Pure selection has a weakness. Once a is driven close to zero, it cannot come back quickly if the world changes. Evolution's fix is mutation: each generation, a small fraction of offspring switch type. The Bayesian fix is to let the hidden state itself change over time, which gives a hidden Markov model. The paper points out that these are the same equation.
The selection half of this was covered above. The mutation half is where biologists and statisticians tend to talk past each other, so this section slows down.
Why this one is hard
A biologist pictures many individuals that exist at once, some of which physically change type when they are copied. A statistician pictures one world with one true state at a time, such as "we are in a wet era", that cannot be seen directly and that sometimes changes. Those pictures do not look alike. Nothing in the world mutates when a microbe does, and no particular microbe holds a belief.
The link is at the level of the whole population. Treat each type as a bet on what the hidden state currently is: the wet specialist is a bet that the era is wet. Then the frequency distribution over types is the population's spread of bets, which is what a statistician calls a belief distribution over the hidden state. On this reading, mutation is not something that happens to the world. It is how the population's bets get spread sideways each generation, and that spreading has a precise statistical meaning: it is the allowance for the possibility that the world has changed since last year.
Reading the equation right to left
Both equations do the same four things in the same order. Take the wet specialist as type i.
| Term | Replicator-mutator | Hidden Markov model filter |
|---|---|---|
| pj(t) | Start with the share of every type j this generation. | Start with the belief in every state j before this year's data. |
| × fj(xt) | Each type reproduces according to its fitness in this year's environment. | Each state is weighted by how well it predicted this year's observation. |
| ÷ f̄ | Divide by mean fitness so shares sum to one. Selection is done. | Divide by the evidence so beliefs sum to one. This is the "update" step. |
| μi←j × | A fraction of type j's offspring are born as type i. | If the state is j now, it will be i next year with this probability. This is the "predict" step. |
| Σj | Add up arrivals from every parent type, including faithful copies from type i itself. | Add up every route by which the world could be in state i next year. |
Two details about the matrix. The arrow in μi←j points from parent j to offspring i, matching P(hi|hj), "i given j". Its diagonal entries μi←i are the fidelity of replication, which on the Bayesian side is the probability that the hidden state stays put.
One year, taken apart
Left column: where the year starts. Middle: after selection. Right: after mutation, which is where next year starts. Blue is the wet specialist, orange the dry specialist. The darker ribbons are the offspring that switch type.
Two things to try. Set the mutation slider to zero: the right column becomes a copy of the middle one and you are back to plain Bayes. Then push the starting share to 99% and press "Carry forward" through several wet years: selection keeps pushing the dry specialist toward nothing, and mutation keeps topping it back up. Selection always moves the population toward whichever type fit this year. Mutation always moves it back toward an even mix.
Notice what the right-hand column is in Bayesian terms. It is not a belief about the year just observed. It is a forecast of the era next year, made before next year's weather arrives. The offspring generation is the population's prediction.
Why it is called filtering
In a hidden Markov model you can ask three questions. Filtering estimates the current state from the history so far. Smoothing goes back and revises estimates of earlier states with the benefit of hindsight. Prediction looks further ahead. The paper identifies replicator-mutator dynamics with filtering specifically, and that fits the biology: a population carries forward only its current composition. It cannot revisit an earlier generation and reweigh lineages that have already died.
A climate that flips between a wet era and a dry era
Blue bands are wet eras (80% of years wet). Elsewhere it is a dry era (20% wet). The line shows the . Two only.
How well does each setting predict next year?
The score is the typical probability the system gave to what happened next (geometric mean). In the evolutionary reading the same number is the population's long-run growth factor per year. A score of 0.5 is coin-flip guessing.
Start with the slider at zero. The line gets stuck after the first long era and takes many years to recover. Raise it a little and the line follows each flip after a short lag. Raise it a lot and the population is too scrambled to commit to anything. The best setting sits near the rate at which the world actually flips.
That result is the core of the parallel. In the model, the mutation rate is the population's built-in assumption about how fast the world changes. A statistician would write that assumption down as a transition probability. A population carries it in its replication machinery. Either way, if it is set too low the system is overconfident and slow to notice change, and if it is set too high the system throws away evidence it has already paid for.
What mutation buys, and what it costs
The next demo isolates one long wet era followed by a flip to dry. The vertical axis is logarithmic so that very small shares stay visible.
The through a long wet era, then a flip
The floor. Without mutation the losing type's share falls in a straight line on this chart, which means exponentially, for as long as the era lasts. With mutation it levels off, because each generation the common type leaks a little into the rare one. Population geneticists call this mutation-selection balance. A statistician would say the model never lets its belief in any state reach zero, because it assumes the state could change at any time.
The recovery. After the flip, the rare type has to climb back from wherever it was. From a floor, that takes a few years, and the wait does not depend on how long the previous era lasted. From an exponential decline, it takes roughly as long as the era that came before. Drag the era length up with mutation at zero and watch the recovery time grow with it.
The cost. During the stable era, the offspring that switch to the wrong type are wasted. Biologists call that mutation load. In the forecasting picture, it is the probability spent each year on a change that did not happen. The table shows both sides of the trade: slightly lower growth while the world is stable, much higher growth across the flip. It works like an insurance premium.
Five misreadings worth avoiding
"Mutation is the population making copying errors." Mechanistically yes. Computationally, in this mapping, it is the prediction step. A filter with no transition step is a filter that assumes the world never changes.
"So the hidden state must be something that mutates." The match is between two matrices of numbers, not between two physical events. The world flips eras for its own reasons. The mutation matrix is the population's standing guess about how such flips happen.
"A higher mutation rate is just more noise." It is a stronger claim that the world is volatile. Like any claim it can be right or wrong, and the score chart shows a penalty on both sides of the right value.
"Some individual must be doing the inference." No individual holds the belief. It exists only as the frequency vector of the population, in the same way that a posterior exists only as the whole set of weights and not in any one hypothesis.
"Real mutation rates are far too low for this." Per-nucleotide rates are tiny compared with the rates on these sliders, and the demos are toy models. The mapping does not require any particular rate. It applies to whatever heritable switching between types a system has. As background from outside the paper: the closest biological cases are fast, reversible switches such as bacterial phase variation, and theoretical work on stochastic phenotype switching (Kussell and Leibler, 2005) concluded that the best switching rate follows the rate of environmental change, which is what the score chart shows.
What the fixed matrix leaves out
In all of this the mutation matrix was given in advance. The filter uses it but never revises it. With more than two types the matrix can also have structure: it can make some switches likely and others rare, which encodes a guess about which changes in the world tend to follow which. Adjusting the matrix itself to fit the pattern of past changes is a slower kind of adaptation, and it is the third rung of the ladder in the timescales section below.
The paper states the equivalence of the two equations, the matrix correspondence and the identification with filtering. The step-by-step reading, the floor, the recovery time and the cost are standard consequences of those equations, worked out here for illustration.
Groups within groups
Genes sit inside cells, organelles inside eukaryotic cells, ants inside colonies. When replicators come packaged in collectives, selection acts both within and between the packages. The paper maps this onto a Bayesian model with two layers of hidden variables.
| Quantity | Multilevel selection | Hierarchical Bayes |
|---|---|---|
| pj | Share of the population living in collective j | Probability of the higher-level variable, P(zj) |
| cij | Composition: share of type i inside collective j | Conditional probability, P(hi | zj) |
| pij = cij pj | Share of all individuals that are type i in collective j | Joint probability, P(hi, zj) |
| fij(x) | Fitness of type i when it lives in collective j | Likelihood, P(x | hi, zj) |
Cooperators and cheaters in two groups
An illustration built for this page. Column width is the group's share of the population. The lower block of each column is its cooperators. Cheaters always out-reproduce cooperators inside their own group, but the cooperator-rich group grows faster.
Press "Next generation" once. Cooperators lose ground inside group A and inside group B, yet gain ground overall, because group A as a whole expanded. The update happens on the joint quantity, . You cannot get the right answer by updating the two levels separately and multiplying. A statistician would say the same about a hierarchical model: the levels are coupled through the data.
When does a new level appear?
Bayesians compare models of different complexity by asking which one predicts the data better on average over its parameter settings. The paper translates that test directly: if a set of replicators has higher average fitness grouped into a collective than living free, a new level of organization emerges. A major evolutionary transition, such as single cells becoming a multicellular body, then reads as the population adopting a richer model structure.
Four timescales, four mechanisms
Environments change at several speeds at once. The paper lines up the mechanisms each system uses for each speed. The first row is the baseline; the three below it are the mechanisms the paper numbers.
One caution from the paper: a function is not itself an adaptive mechanism. It is the product of adaptation running at a slower timescale, the way a neural network's weights are the slow product of training while its activations do the fast work.
Finite populations: particle filters and Wright-Fisher
Everything so far used exact frequencies, as if populations were infinite. Real ponds hold a finite number of microbes, and real computers cannot track every hypothesis. Statisticians handle this with a particle filter: keep N samples, weight them, resample, perturb. Population geneticists have the Wright-Fisher model: N individuals, each generation drawn from the last in proportion to fitness, with mutation. The paper lays out the two algorithms and they match step for step.
With N = 10 the solid line lurches around the dashed one. Biologists call that genetic drift; statisticians call it sampling error. With N = 1000 the two lines nearly coincide. In the limit of infinite N the Wright-Fisher population reproduces exact filtering, and with mutation switched off as well it reproduces plain Bayesian updating.
What the comparison raises
When to resample. In a particle filter, resampling is an optional, costly step that keeps the particle set from collapsing onto a few heavy weights. Biology rarely has the option to skip it: organisms die, so lineages persist only by copying. The paper mentions clonal plants and colonial animals as the nearest thing to "accumulating weight without resampling", since the colony grows instead of splitting.
Recombination. Sexual populations shuffle discrete modules between parents, which lets them respond faster to directional selection. Some particle filters and many evolutionary algorithms borrow this. The authors ask what recombining hypotheses would look like in a brain or a machine.
What counts as a hypothesis. To run this algorithm, a hypothesis only has to be copyable, mutable and evaluable. It does not need gradients or a fixed parameter list, which is why the authors see it as a route to learning over open-ended, combinatorial hypothesis spaces.
What the population is optimizing
If a population computes, there should be a quantity it steadily improves. For selection that does not depend on frequencies, Fisher's fundamental theorem supplies one: mean fitness never decreases. The paper adds an information-theoretic version that also covers frequency-dependent cases: the Kullback-Leibler divergence between the current frequencies and the steady state always shrinks.
Five in a constant
However the starting frequencies are shuffled, one curve only rises and the other only falls. The authors' larger point follows from the earlier sections: the frequencies are not just a record of which type is currently best. Taken as a whole distribution they are the best available summary of past environments for predicting the next one, and this holds with no help from evolvability or multilevel selection.
Where the analogy breaks
The paper is explicit about limits and sorts them into two kinds.
Structural mismatch: normalization
A likelihood must spread a total of 1 across all possible observations. A hypothesis that says "rain: 90%, no rain: 90%" is not allowed. A strain with fitness 0.9 in wet years and 0.9 in dry years is perfectly possible. Biology has soft physical trade-offs where probability theory has a hard budget.
Structural mismatch: frequency dependence
How well a hypothesis explains the data does not depend on how much you already believe it. How well a strategy does often depends on how common it is. The general replicator equation covers this; Bayes' rule does not. The demo below shows the difference.
Model gap: competing for resources
No exact Bayesian twin exists yet for ecological resource competition. The authors see a family resemblance to the Expectation-Maximization algorithm for mixture models, where components compete to "own" data points.
Model gap: changing the environment
Organisms build nests, dams and soils, which changes the selection they face (niche construction). The learning-side counterpart is active inference, where an agent acts on the world it is modeling.
One more open question: the clean match is with asexual, haploid populations. How it extends to sexual and diploid ones has not been worked out.
Hawks and doves: a contest Bayes' rule cannot express
Hawks fight over a resource worth 2 and risk an injury cost. Doves share or back down. A hawk's fitness depends on how many other hawks there are. Each line is a population with a different starting share of hawks.
In every Bayesian demo above, one hypothesis eventually took over and the starting point decided how long that took. Here every start ends at the same mixture and neither type wins.
Evidence and uses
The paper cites simulation studies in which evolving populations do what a learner would do: remember and generalize.
RNA that remembers
Simulated RNA populations were selected to fold toward target shape A, then toward B, then A again. The second adaptation to A went faster than the first. Populations also adapted quickly to a new target C, as long as C belonged to the same "grammatical" family of shapes as A and B.
Gene networks that behave like neural networks
Simulated gene regulatory networks under alternating selection stored several target expression patterns. Their memory capacity, their gradual loss of recall as connections are removed, and a Hebbian-style rule (genes expressed together evolve to activate each other) all matched what is known for neural networks.
An outer loop and an inner loop
Genetic evolution and Bayesian cognition can be seen as two nested versions of one adaptive scheme. Evolution, the slow outer loop, builds the brain's priors and its machinery for generating and testing ideas. Once that inner loop is fast and capable, genetic selection on cognition can relax. The paper links this to proposals about relaxed selection in human evolution and to the idea that cultural variants, not genes, now do much of the evolving in our species.
Three places the authors expect this to matter
Explaining Darwinian systems. Any system with replication, variation and selection can be asked what cost function it minimizes or what inference it performs. Candidates include cultural evolution, Darwinian accounts of neural dynamics, and quantum Darwinism, where replicator models are still unproven.
Understanding brains. Much of cognition is well described as Bayesian inference, but how neurons implement it is unsettled. Copying and evaluating neural patterns, in the manner of a particle filter, is one candidate.
Designing AI. Bayesian methods extract information efficiently; evolutionary search generates novelty in open-ended spaces. A shared mathematical language could help combine them. The authors propose Bayesian graphical models, the node-and-arrow diagrams shown on this page, as that language for evolutionary modeling, while saying plainly that not all of evolution will fit.