Natural Selection for Computer Scientists

The biology that evolutionary algorithms borrow, stated as biologists state it: the three conditions for selection, fitness as reproductive success, genes, alleles, genotype and phenotype, mutation, recombination, genetic drift, and the modern synthesis. For each, what an evolutionary algorithm keeps, simplifies, or discards. Worked through in numbers: the haploid selection recursion, the breeder's equation on a noisy fitness function, Wright-Fisher fixation probabilities against the diffusion formula, and a seeded experiment on drift in a small population.

Natural selection needs only Lewontin's three conditions: variation, differential fitness and heritability. An evolutionary algorithm (EA) keeps all three but replaces fitness, realized reproductive success, with a fixed score. On fixed fitness values the haploid recursion multiplies the odds of the fitter type by $1 + s$ each generation, and mean fitness rises by $\operatorname{Var}(w)/\bar w$. Under noisy evaluation the response to selection is $R = h^2 S$: on 100-bit OneMax the measured $R/S$ was 1.00, 0.51 and 0.18 for $h^2 = 1$, 0.5 and 0.2. Kimura's diffusion formula $u(p) = (1 - e^{-2Nsp})/(1 - e^{-2Ns})$ gives the fixation probability, about $2s$ for a new mutation when $Ns \gg 1$. With 50 strings, uniform crossover and no mutation, drift fixed a median of 30 of 100 OneMax loci wrongly under fitness-proportional selection, and 2 under tournament selection.

Two strains of bacteria grow in a flask of nutrient broth with food to spare. One divides slightly faster than the other. Nothing struggles, nothing starves, and no individual is killed, yet after enough generations the faster strain makes up nearly the whole culture. Richard Lewontin used this example to make a point about Darwin's theory: competition for scarce resources is not part of its logic (Lewontin, 1970). If not a struggle for survival, what does natural selection actually need, and how much of it do evolutionary algorithms borrow?

Natural selection is the process by which heritable variants that leave more offspring become more common in a population. What it needs is less dramatic than a struggle and more general: variation among individuals, differences in how fast the variants reproduce, and heritability. Those three conditions are exactly the part that evolutionary algorithms borrow. This article assumes the loop described there: a population, parent and survivor selection, recombination and mutation.

The plan is to set out the biology as biologists state it, and then say for each idea what an evolutionary algorithm (EA) keeps, what it simplifies, and what it leaves out. First come Lewontin's three conditions for selection, and what fitness means in biology. Then we turn selection into arithmetic and predict how fast a fitter type spreads. Next come heredity and variation, and how much of a selected advantage is passed on when fitness is measured with noise. Then we see how chance competes with selection in small populations, which EA populations always are. Finally we place all of this in the modern synthesis and collect the comparisons in one table.

Eiben and Smith (2015, ch. 2) give a short account of the same inspiration, explicitly simplified. The aim here is to be precise about the simplifications, because several common misunderstandings about EAs start with a biological word used in a sense biology does not give it. This article is the course's home for relative fitness, heritability and genetic drift; later articles on selection pressure and diversity build on it. The limits of the evolutionary metaphor take up the consequences.

Selection in three conditions

Darwin (1859) argued that species change over time by natural selection acting on heritable variation. He did not know how inheritance worked. Lewontin (1970) reduced the argument to three principles that make no assumption about mechanism:

  1. Variation. Individuals in a population differ in their morphology, physiology, and behavior.
  2. Differential fitness. Different variants survive and reproduce at different rates.
  3. Heritability. Offspring resemble their parents, so that parents' fitness is correlated with their offspring's.

While all three hold, the population changes. Lewontin stressed how little the principles specify. Inheritance can be genetic, cytoplasmic, or cultural, and the reason one variant out-reproduces another is left open. Any set of entities with variation, reproduction, and heritability can evolve. That is why the principles transfer to programs and bitstrings at all.

Example (the flask of bacteria). The flask meets all three conditions, even though no cell dies. The two strains are the variation. The faster-dividing strain reproduces at a higher rate, which is differential fitness. And each cell's daughters belong to its own strain, which is heritability. Nothing in the three conditions mentions death or scarcity.

What an EA keeps. All three, deliberately. A population of candidate solutions supplies variation, a selection operator makes reproduction depend on a score, and copying with small changes makes offspring resemble their parents.

What it adds. The principles say that the population changes. They do not say that it improves, still less that it finds anything best. An EA becomes an optimizer only because its designer fixes what counts as fitness and holds it constant. The word "fitness" therefore means something different on each side, and the next section sets the two meanings out.

Fitness is reproductive success

In biology, fitness is a measure of reproductive success. Roughly, it is the expected number of offspring an individual or a genotype contributes to the next generation, usually expressed relative to the rest of the population (Futuyma and Kirkpatrick, 2017). Three features of this definition matter for computing.

  • Fitness is an outcome, not a cause. No organism is scored. Fitness describes how many descendants a variant leaves, which is the result of everything it does in its environment. "Survival of the fittest" is therefore close to circular if read as a law, and biologists do not use it as one.
  • Fitness is relative and environment-dependent. A variant that is fitter in one environment can be less fit in another, and the environment includes the other members of the population. When the advantage of a variant depends on how common it is, fitness changes as the population changes.
  • Fitness is a property of a variant in context, not of a design. Selection favors whatever leaves more descendants now. It does not look ahead.

What an EA does instead. An EA defines an explicit fitness function that maps each candidate to a number before reproduction happens. It uses that number to decide who reproduces (parent selection) and who stays in the population (survivor selection) (Eiben and Smith, 2015, ch. 5). In most EAs the fitness function is fixed for the whole run. It is a property of the candidate alone, so it does not depend on what else is in the population, and it encodes what the designer wants.

The two meanings meet in one place. Under fitness-proportional selection, a population of $N$ individuals with fitness values $f_1, \dots, f_N$ chooses each parent with probability $f_i / \sum_j f_j$. Over $N$ draws, individual $i$ receives on average

$$N \cdot \frac{f_i}{\sum_j f_j} = \frac{f_i}{\bar{f}}$$

copies, where $\bar{f}$ is the population's mean fitness. That ratio is exactly the biologist's relative fitness: expected offspring compared with the average.

Example (the best string of the hand-traced run). Under fitness-proportional selection the best string, D, expects $1.33$ copies from four draws. In the hand-traced run of the evolutionary algorithm loop, the four strings had fitness 3, 4, 3 and 5. D's fitness is 5 and the mean is $15/4 = 3.75$, so it expects $5/3.75 = 1.33$ copies, the figure in that article's table. Its relative fitness is $4/3$.

Other schemes, such as tournament selection, give each individual an expected number of offspring that depends only on its rank. The number the fitness function returns is then just an ordering. Either way, the algorithm's "fitness" is an engineering quantity that becomes reproductive success only through the selection operator. Selection pressure is the measure of how strongly that operator favors the best.

What an EA discards. Coevolution aside, the moving environment: in nature the target shifts as other species evolve. Competitive coevolution restores this feature on purpose, and with it some of the instability that natural evolution shows, such as Red Queen dynamics.

Selection as arithmetic

Relative fitness becomes a prediction once it is written as a recursion. How fast does a fitter type spread? Here is the idea in one sentence: under selection on fixed fitness values, the odds that a random individual is of the fitter type are multiplied by the same factor every generation. The derivation makes that exact.

The formal version. Take the simplest case population genetics studies: a large population of haploid individuals (one copy of each gene) of two types, A and a. Their relative fitnesses are $w_A = 1 + s$ and $w_a = 1$. The number $s$ is the selective advantage of A: $s = 0.1$ means that A leaves 10% more offspring on average. Let $p$ be the frequency of A in one generation.

  1. Each type contributes offspring in proportion to its frequency times its fitness: $p\, w_A$ for A and $(1 - p)\, w_a$ for a.
  2. The total, which is the population's mean fitness, is $\bar w = p\, w_A + (1 - p)\, w_a = 1 + s p$.
  3. Dividing A's share by the total gives its frequency in the next generation:

$$p' = \frac{p\, w_A}{\bar w} = \frac{p (1 + s)}{1 + s p}.$$

This is the same expression as fitness-proportional selection, $f_i / \bar f$ copies per individual, written for two types instead of $N$ individuals.

The recursion has a closed form. The frequency of type a in the next generation is

$$1 - p' = \frac{(1 + sp) - p(1 + s)}{1 + sp} = \frac{1 - p}{1 + sp}.$$

Divide the equation for $p'$ by this one. The denominators $1 + sp$ cancel and leave

$$\frac{p'}{1 - p'} = (1 + s)\, \frac{p}{1 - p},$$

so the odds $p/(1 - p)$ are multiplied by exactly $1 + s$ each generation. After $t$ generations,

$$\frac{p_t}{1 - p_t} = (1 + s)^t\, \frac{p_0}{1 - p_0}.$$

The check. Start from $p_0 = 0.01$ with $s = 0.1$. The odds start at $1/99$ and must reach $99$ for A to make up 99% of the population, a factor of $99^2 = 9{,}801$. That takes $\ln 9{,}801 / \ln 1.1 \approx 96.4$ generations, so the frequency first exceeds 0.99 in generation 97. The script tools/experiments/evolution/selection_dynamics.py iterates the recursion and asserts that it agrees with the closed form at every generation from 0 to 100 (values rounded to four decimals):

Generation $t$ $p_t$ $\bar w_t$
0 0.0100 1.0010
10 0.0255 1.0026
20 0.0636 1.0064
30 0.1498 1.0150
40 0.3137 1.0314
50 0.5425 1.0542
60 0.7546 1.0755
80 0.9539 1.0954
100 0.9929 1.0993

The curve is an S shape. For 30 generations A is rare, and its frequency grows by about 10% per generation in relative terms, barely visible in absolute terms. Most of the change happens in the middle. The last stretch is slow again, because a has become rare and is replaced at a rate proportional to its own small frequency.

Example (half the advantage). If the advantage is halved to $s = 0.05$, the same takeover takes about twice as long. The number of generations is $\ln 9{,}801 / \ln(1 + s)$, and for small $s$ the denominator $\ln(1 + s)$ is close to $s$ itself. With $s = 0.05$ it is $\ln 9{,}801 / \ln 1.05 \approx 188.4$ generations against 96.4, a ratio of 1.95. The left panel of the figure below shows it: halving $s$ roughly doubles the time the S-shaped curve takes.

Mean fitness rises

Why must mean fitness rise throughout the table? The reason can be stated in one line. Let type $i$ have frequency $p_i$ and constant fitness $w_i$, so that $\bar w = \sum_i p_i w_i$ and selection gives $p'_i = p_i w_i / \bar w$, as in step 3 above. Then $\bar w' = \sum_i p'_i w_i = \sum_i p_i w_i^2 / \bar w$, and

$$\bar w' - \bar w = \frac{\sum_i p_i w_i^2 - \bar w^2}{\bar w} = \frac{\operatorname{Var}(w)}{\bar w} \ge 0.$$

The last equality is the definition of the variance of fitness over the population, $\operatorname{Var}(w) = \sum_i p_i w_i^2 - \bar w^2$.

Selection on fixed fitness values raises mean fitness by the variance in fitness divided by its mean. It stops raising it only when the variance is gone. In the first generation of the table, $\operatorname{Var}(w) = s^2 p (1 - p) = 0.000099$, and $\bar w$ rises from 1.0010 to 1.0011.

The condition "fixed fitness values" is exactly the one an EA meets and nature does not. The limits of the evolutionary metaphor gives a case where selection lowers mean fitness instead.

The same arithmetic inside an EA

Back to OneMax. Suppose a population of 50 OneMax strings all have fitness 50, except one copy of a string with an extra 1, fitness 51.

  • Fitness-proportional selection. The better string's advantage is $s = 1/50 = 0.02$. The recursion says it needs $\ln(49^2)/\ln 1.02 \approx 393$ generations, 394 when iterated, to go from 1 copy in 50 to 49 in 50.
  • Binary tournament selection. The better type wins any tournament it enters. It is absent from a tournament only when both entrants are the other type, so $p' = 1 - (1 - p)^2 = p(2 - p)$. At small $p$ this doubles the frequency every generation, whatever the fitness values are. The same takeover needs 8 generations: 0.020, 0.040, 0.078, 0.149, 0.276, 0.476, 0.726, 0.925, 0.994.
Left: the frequency of type A under the haploid recursion from 1%, for selective advantages 0.2, 0.1 and 0.05. Notice that halving s roughly doubles the time the S-shaped curve takes. Right: one fitter string among 50, on a logarithmic generation axis. Binary tournament selection takes it over the population in 8 generations; fitness-proportional selection, which sees an advantage of only 1/50, needs 394.
Left: the frequency of type A under the haploid recursion from 1%, for selective advantages 0.2, 0.1 and 0.05. Notice that halving s roughly doubles the time the S-shaped curve takes. Right: one fitter string among 50, on a logarithmic generation axis. Binary tournament selection takes it over the population in 8 generations; fitness-proportional selection, which sees an advantage of only 1/50, needs 394.

The contrast is the deterministic version of the drift experiment later in this article. There, fitness-proportional selection on OneMax lost dozens of loci that tournament selection kept. Before chance enters, though, we need the units that selection acts on and inheritance passes on.

Heredity: genes, alleles, genotype, phenotype

Darwin's mechanism needed heredity but lacked a theory of it. Gregor Mendel's crosses of garden peas, published in 1866, showed that traits are passed on as discrete units that do not blend (Mendel, 1866). The units came to be called genes.

  • A gene is a unit of heredity, in molecular terms a stretch of DNA that is transcribed into a functional product.
  • A locus is the position of a gene on a chromosome.
  • An allele is one of the alternative variants that can occupy a locus. Most animals are diploid, carrying two copies of each chromosome and so two alleles at each locus, one from each parent.

Wilhelm Johannsen introduced the terms in 1909 and set out in English the distinction between genotype, the hereditary constitution of an organism, and phenotype, its observable characteristics (Johannsen, 1911). The phenotype is produced by development, the long process by which a genotype builds an organism in interaction with its environment. Selection acts on phenotypes. Only genotypes are inherited.

What an EA keeps. The vocabulary, mapped onto data structures (Eiben and Smith, 2015, ch. 3). The loop already used genotype for the encoding and phenotype for the solution; here is how the rest of the words map. In a genetic algorithm on bitstrings, the string is the chromosome or genotype, each position is a locus, and the value 0 or 1 at a position is its allele. The phenotype is the solution the string represents, such as a set of real-valued parameters decoded from the bits by a binary or Gray code. Fitness is computed from the phenotype.

What it simplifies. The genotype-to-phenotype map is usually a direct decoding, with no development, no environmental influence, and no noise. EAs are almost always haploid: one string per individual, no dominance, no pairs of alleles. A few representations reintroduce indirect, development-like mappings:

  • the grammar-based mappings of grammatical evolution, which turn an integer string into a program;
  • the compositional pattern-producing networks of HyperNEAT, where a small genotype generates a large, regular phenotype.

What it can break. Biological inheritance does not pass on traits an organism acquires in its lifetime; the phenotype does not write back to the genotype. An EA is free to break this rule.

Example (memetic algorithms). A memetic algorithm improves each offspring with a local search such as hill climbing before it is evaluated. If it then copies the improved solution back into the genotype, it lets an acquired trait be inherited, which is Lamarckian inheritance and breaks the biological rule. Alternatively, a memetic algorithm may keep the original genotype but score it by the improved phenotype. That is called the Baldwinian variant (Eiben and Smith, 2015, ch. 10), and it respects the biological rule.

Variation: mutation and recombination

Genes explain what is inherited. New variants come from two sources: mutation, which changes a gene, and recombination, which rearranges existing ones.

Mutation in biology is any change in the DNA sequence: a substituted nucleotide, an insertion or deletion, a duplicated gene, a rearranged chromosome. Mutation is random with respect to its effect: it does not occur preferentially where it would help. Most mutations that affect fitness are harmful, and many have little or no effect. Rates are low. In humans, Kong and colleagues (2012) measured an average of $1.20 \times 10^{-8}$ new mutations per nucleotide per generation. Over a diploid genome of about $6 \times 10^9$ nucleotides, that is roughly 70 new mutations per child.

Recombination shuffles existing variation. In sexual reproduction, meiosis assigns each gamete one copy of each chromosome, chosen independently. Before the copies separate, crossing over exchanges segments between the two copies of a chromosome. Each offspring therefore carries a new combination of its parents' alleles. Because the paired chromosomes are aligned gene by gene, crossing over normally exchanges corresponding segments.

What an EA keeps. Both kinds of variation, as operators the designer chooses (see crossover and mutation operators). Bit-flip mutation flips each bit independently with a small probability. One-point or uniform crossover combines two parent strings position by position, much as aligned chromosomes do.

What it changes. The rates and the targets.

  • Rates. A common default flips each bit with probability $1/L$ for a string of length $L$, so each offspring carries one mutation on average. For $L = 100$, the per-site rate is 0.01, nearly a million times the human rate of $1.2 \times 10^{-8}$.
  • Targets. Mutation in an EA need not be blind to the problem. Operators are designed for a representation, and self-adaptive evolution strategies evolve their own mutation step sizes.
  • Constraints. Recombination need not respect any biological constraint. It can combine three parents, average real-valued vectors, or be omitted entirely.

Heritability: how much of selection is passed on

Lewontin's third condition, heritability, is not all or nothing. Offspring resemble their parents more or less closely, and the degree sets how much of a selected difference reaches the next generation. Plant and animal breeders measure it with two numbers.

  • The selection differential $S$ is how much better the selected parents are than the population they came from, measured on the trait being selected.
  • The response $R$ is how much better their offspring are than that same population.

The ratio $R/S$ is the realized heritability.

An EA with a noisy fitness function shows why the ratio can be well below 1. Here is the idea in one sentence: selection on a noisy score picks partly real quality and partly luck in the measurement, and only the real part is inherited.

The formal version. Suppose each candidate has a true quality $g$, but every evaluation returns $z = g + e$. The noise $e$ is drawn independently each time, with mean 0 and variance $\sigma_e^2$. Selection sees only $z$. The derivation takes three steps.

  1. What selection on $z$ does to $g$. The best linear prediction of $g$ from $z$ is $\bar g + h^2 (z - \bar z)$. Its slope is $h^2 = \operatorname{cov}(g, z) / \operatorname{Var}(z) = \sigma_g^2 / (\sigma_g^2 + \sigma_e^2)$, the share of the measured variance that is real. Here $\sigma_g^2$ is the variance of $g$ over the population. The noise is independent of $g$, so $\operatorname{cov}(g, z) = \operatorname{cov}(g, g) + \operatorname{cov}(g, e) = \sigma_g^2$ and $\operatorname{Var}(z) = \sigma_g^2 + \sigma_e^2$. The linear prediction equals the true mean of $g$ at each value of $z$ when $g$ and $e$ are normally distributed. For OneMax, where $g$ is a sum of many bits and so only approximately normal, that equality is not proved here; the experiment below tests the result. Averaging the prediction over the selected parents, whose mean $z$ exceeds $\bar z$ by $S$, gives a mean true quality of $\bar g + h^2 S$.
  2. What crossover passes on. On a problem where every bit contributes separately to $g$, such as OneMax, uniform crossover takes each bit from one parent or the other with probability $\tfrac12$. So a child's expected $g$ is the mean of its two parents' $g$. Averaged over all children, the population of offspring has mean true quality $\bar g + h^2 S$.
  3. What the next evaluation sees. The noise has mean 0, so the offspring's mean measured fitness is also $\bar g + h^2 S$, and the response is

$$R = h^2 S.$$

This is known in breeding as the breeder's equation. Here $h^2$ plays the role of heritability, and in this setting it is fixed by the noise.

Example (noise as large as the signal). If the noise variance equals the variance of true quality, half of the selection differential reaches the offspring. With $\sigma_e^2 = \sigma_g^2$, the formula gives $h^2 = \tfrac12$, so $R = S/2$. The middle row of the table below tests exactly this case.

The check. The script tools/experiments/evolution/selection_dynamics.py checks the equation on OneMax with 100 bits and a population of 1,000. In a random population $g$ has variance $100 \cdot \tfrac14 = 25$. Each run is a single generation from a random population, which is where the variance of 25 holds:

  • truncation selection keeps the better half by measured fitness;
  • uniform crossover of random pairs of the selected parents makes 1,000 children, without mutation;
  • the children are measured with fresh noise.

Thirty seeded runs per noise level, median with interquartile range in brackets, rounded to two or three decimals:

Noise $\sigma_e$ $h^2 = 25/(25 + \sigma_e^2)$ $S$ $R$ $R/S$
0 1 4.00 3.99 1.00 [0.97, 1.02]
5 0.5 5.67 2.83 0.51 [0.46, 0.53]
10 0.2 8.93 1.60 0.18 [0.15, 0.25]

The selection differential grows with the noise, because the measured values spread out, yet the response shrinks. The size of $S$ follows from the normal distribution. The mean of the upper half of a standard normal variable is $2 \int_0^\infty x\, \varphi(x)\, dx = 2 \varphi(0) = \sqrt{2/\pi} \approx 0.798$, where $\varphi$ is the standard normal density and $-\varphi(x)$ is an antiderivative of $x \varphi(x)$. So truncation to the better half gives $S \approx 0.798\, \sigma_z$ with $\sigma_z = \sqrt{25 + \sigma_e^2}$: 3.99, 5.64 and 8.92 for the three rows, against the measured 4.00, 5.67 and 8.93. The constant is for an infinite population. For the best 500 of a finite sample of 1,000 normal values the script's simulation gives 0.797. Much of what selection picks out is luck in the measurement, and luck is not inherited.

This is the precise sense in which noisy evaluation weakens an EA: it lowers the heritability of fitness. Selecting harder raises $S$, but only the fraction $h^2$ of the extra differential is passed on. Raising $h^2$ improves every generation's return instead. One way is to average $k$ repeated evaluations of each candidate, which divides $\sigma_e^2$ by $k$.

Genetic drift

So far every source of change has been systematic. But a finite population also changes by chance.

In a finite population, which individuals happen to reproduce is partly a matter of chance. So the frequency of an allele wanders from generation to generation even when it has no effect on fitness. This is genetic drift. Without new mutation, drift eventually fixes or eliminates every neutral allele. Frequencies 0 and 1 are the only ones that cannot change, since an absent allele has no copies to pass on. From any other frequency there is a positive chance that the next generation's parents all happen to carry the allele, so sooner or later the frequency lands on 0 or 1 and stays there.

A neutral allele at frequency $p$ becomes fixed, present in every individual, with probability $p$. The reason is a symmetry. Tag the descendants of each present individual with that individual's name. A tag behaves like a neutral allele, so by the argument just given each tag is eventually lost or fixed. The population never becomes empty, so exactly one tag is fixed, and the whole population then descends from that one individual. With no fitness differences, each present individual is equally likely to be that ancestor. The allele is fixed exactly when the ancestor carries it, and a fraction $p$ of the individuals do.

The same answer follows from a martingale argument. Under neutrality the expected frequency in the next generation equals the current one, so the frequency is a bounded martingale that ends at 0 or 1. The optional stopping theorem (Theorem 3 of Random Walks and Martingales) then makes its expected final value, which is the fixation probability, equal to its starting value $p$.

Drift is stronger in small populations. A common rule of thumb is that selection dominates an allele's fate only when its selective advantage $s$ is large compared with the reciprocal of the population size. When $s$ is comparable to $1/N$ or smaller, the allele behaves almost as if it were neutral (Futuyma and Kirkpatrick, 2017). Kimura (1968) argued that much of evolutionary change at the molecular level is the fixation of neutral mutations by drift, not adaptation.

Drift against selection, in numbers

The rule of thumb can be made exact enough to compute with. The Wright-Fisher model adds sampling to the recursion of the previous section. A population has exactly $N$ haploid individuals. To form the next generation, each of $N$ slots is filled independently by a copy of type A with probability $p(1+s)/(1+sp)$, the frequency that selection alone would give. So the number of A in the next generation is a binomial draw, with $N$ trials and success probability $q = p(1+s)/(1+sp)$, whose variance $Nq(1-q)$ is derived in The Binomial Distribution. Selection sets the expected direction, and the binomial draw adds noise whose size depends on $N$.

The frequency of a type with advantage s = 0.05, starting at 10%, in 20 Wright-Fisher populations of each size. With N = 20 (left), notice how the paths jump about and most hit zero within a few generations: A was lost in 15 populations and fixed in 5. With N = 500 (right), the paths stay close to the dashed deterministic curve, and A had fixed in 19 of the 20 by generation 200 and was still present in the last.
The frequency of a type with advantage s = 0.05, starting at 10%, in 20 Wright-Fisher populations of each size. With N = 20 (left), notice how the paths jump about and most hit zero within a few generations: A was lost in 15 populations and fixed in 5. With N = 500 (right), the paths stay close to the dashed deterministic curve, and A had fixed in 19 of the 20 by generation 200 and was still present in the last.

The probability that A takes over in the end has a closed form, derived next. Here is the plan of the derivation. We describe one generation's move by its mean and its variance. We then require that the chance of eventual fixation be the same, on average, before and after one generation. That gives a differential equation whose solution is the fixation probability.

The formal version. The diffusion approximation treats $p$ as a continuous quantity that moves a little each generation. Two numbers describe one generation's move.

  • The mean change is $\dfrac{p(1+s)}{1+sp} - p = \dfrac{p + sp - p - sp^2}{1+sp} = \dfrac{sp(1-p)}{1+sp} \approx s p (1 - p)$ for small $s$.
  • The variance of the change is that of a binomial frequency, $q(1-q)/N \approx p(1-p)/N$, where $q$ is the probability used for the draw.

Let $u(p)$ be the probability that A is eventually fixed when its frequency is $p$. One generation later the frequency is $p + \Delta p$, and the eventual outcome is the same random event, so $u(p)$ equals the average of $u(p + \Delta p)$. Expanding $u(p + \Delta p)$ to second order and averaging,

$$u(p) \approx u(p) + u'(p)\, \mathrm{E}[\Delta p] + \tfrac12 u''(p)\, \mathrm{E}[\Delta p^2].$$

Here $\mathrm{E}[\Delta p] \approx s p (1 - p)$ is the mean change. The mean square $\mathrm{E}[\Delta p^2]$ is the variance plus the square of the mean, $p(1-p)/N + s^2 p^2 (1-p)^2$, and the second term is dropped. It is smaller than the first by the factor $N s^2 p (1 - p)$, which is small when $N s^2 \ll 1$, that is, when $s$ is small compared with $1/\sqrt{N}$. That is the usual setting of the diffusion approximation, and the factor $1/(1+sp)$ in the mean was dropped on the same grounds. When selection is stronger the formula is no longer accurate to that order. It remains a good guide for a new mutation, whose fate is mostly settled while $p$ is near 0 and the factor is still small. The check below measures the error in such a case. Substituting both and canceling $u(p)$ gives

$$u'(p)\, s p (1 - p) + \tfrac12 u''(p)\, \frac{p(1-p)}{N} = 0,$$

and dividing by $p(1-p)$:

$$s\, u'(p) + \frac{1}{2N} u''(p) = 0.$$

This says $u'' = -2Ns\, u'$, so $u'(p) = c\, e^{-2Nsp}$ for a constant $c$. Integrating from 0 to $p$, with $u(0) = 0$ because A is already lost at frequency 0, gives

$$u(p) = c \int_0^p e^{-2Nsx}\, dx = \frac{c}{2Ns} \left(1 - e^{-2Nsp}\right).$$

At frequency 1 A is already fixed, so $u(1) = 1$, which sets $c/(2Ns) = 1/(1 - e^{-2Ns})$. Therefore

$$u(p) = \frac{1 - e^{-2Nsp}}{1 - e^{-2Ns}}.$$

This is the haploid form of the fixation formula of Kimura (1962). For diploids, with $s$ the advantage that one copy of the allele gives, the same derivation gives $4N_e s$ in place of $2Ns$, because a diploid population of $N_e$ individuals carries $2N_e$ copies of each gene, which halves the variance of one generation's change.

Everything in the formula depends on $s$ and $N$ only through their product $Ns$, which is the exact form of the rule of thumb.

Example (a new mutation with a 5% advantage). A single new mutation with a 5% advantage is not nearly certain to take over, even in a very large population: it is lost about nine times in ten. The second of the three cases below shows why.

  • Neutral, $s \to 0$. For small $x$, $1 - e^{-x} \approx x$. Applied to both exponentials, $u(p) \to 2Nsp / (2Ns) = p$. A neutral allele fixes with probability equal to its frequency, in agreement with the symmetry argument above.
  • Strong selection, $Ns \gg 1$. The denominator is close to 1, since $e^{-2Ns}$ is tiny. A single new copy has $p = 1/N$, so the numerator is $1 - e^{-2s}$, and it fixes with probability $1 - e^{-2s} \approx 2s$. So a new mutation with a 5% advantage fixes with probability about 0.1, however large the population. It starts as one copy and can be lost by chance before selection has had time to act.
  • Harmful, $s < 0$ with $N|s| \gg 1$. Write $s = -|s|$ and multiply numerator and denominator by $-1$: $u(p) = (e^{2N|s|p} - 1)/(e^{2N|s|} - 1)$. For a single copy, $p = 1/N$, this is $(e^{2|s|} - 1)/(e^{2N|s|} - 1) \approx 2|s|\, e^{-2N|s|}$. The probability falls off exponentially in $N|s|$. Small populations can fix harmful alleles; large ones almost never do.

The check. The script tools/experiments/evolution/selection_dynamics.py checks the formula by simulation: for each $N$ and $s$, 30 seeded batches of 2,000 populations, each started with one copy of A.

Probability that a single new copy of A eventually fixes, against its advantage s, for populations of 10, 50 and 200. Points are simulation medians over 30 batches with interquartile ranges; lines are the diffusion formula; the dotted line is 2s. At s = 0 each curve passes through 1/N. Notice that for N = 200 the curve hugs zero for harmful alleles and approaches 2s for helpful ones, while for N = 10 it is nearly a straight line through 1/N, because there drift dominates every value of s shown.
Probability that a single new copy of A eventually fixes, against its advantage s, for populations of 10, 50 and 200. Points are simulation medians over 30 batches with interquartile ranges; lines are the diffusion formula; the dotted line is 2s. At s = 0 each curve passes through 1/N. Notice that for N = 200 the curve hugs zero for harmful alleles and approaches 2s for helpful ones, while for N = 10 it is nearly a straight line through 1/N, because there drift dominates every value of s shown.

The simulated and approximate values agree to within 0.007 everywhere in this range.

  • For $N = 50$ and $s = 0.02$ the simulation gives 0.046 and the formula 0.045.
  • For $N = 200$ and $s = 0.1$ they are 0.176 and 0.181. Here $N s^2 = 2$, so the condition $N s^2 \ll 1$ of the derivation does not hold. The script also solves the Wright-Fisher chain exactly, as a linear system over the 201 possible counts of A, and gets 0.1760. The chain is absorbing, with absorbing states 0 and $N$, and the fixation probability is its probability of absorption in $N$, the quantity Theorem 8 of Markov Chains and Stationary Distributions computes from the fundamental matrix. So the simulation is right and the formula is 0.0053 too high, an error of 3%. In the first case, where $N s^2 = 0.02$, the exact value is 0.0451 and the formula is within 0.0003 of it.
  • For $N = 20$, $s = 0.05$ and $p_0 = 0.1$, the case on the left of the trajectory figure, the formula gives 0.210 and the exact chain 0.207, so about 4 of the 20 populations should fix A; 5 did. For $N = 500$ the formula gives 0.993, and so does the exact chain.
Twenty Wright-Fisher populations. Choose the population size N, the advantage s of type A and its starting frequency, and compare how often A fixes with the diffusion formula in the readout. Small N with small s looks like noise; large N with the same s looks like the dashed deterministic curve.

Drift inside an EA

EA populations are tiny by biological standards, typically tens to hundreds of individuals, so drift is strong. The script tools/experiments/evolution/neutral_drift.py in the site repository measures it. Each run uses $N = 50$ random bitstrings of length 20 and no mutation, so the only sources of change are selection and sampling. All results are over 30 seeded runs.

Neutral, no crossover. Every individual has the same fitness, so each generation draws 50 parents uniformly at random with replacement. This is the haploid Wright-Fisher model of population genetics. Every run ended with all 50 individuals descended from a single founder, after a median of 95.5 generations (interquartile range 71 to 128.5; minimum 42, maximum 228). Coalescent theory predicts a mean of about $2N(1 - 1/N) = 98$ generations. The 30 runs averaged 107.3. The standard deviation of this time is about 53 generations, so a 30-run mean has a standard error of about 10, and the observed mean is about one standard error above the prediction.

The prediction comes from following lineages backward in time. The whole population at generation $t$ descends from one founder exactly when its $N$ lines of ancestry have merged into one within $t$ generations. Suppose $k$ distinct lines remain. Each picks its parent uniformly among $N$ individuals, so a given pair picks the same parent with probability $1/N$. With $\binom{k}{2}$ pairs, and if two mergers in one generation are neglected, some pair merges with probability about $\binom{k}{2}/N$ per generation. The expected wait is $N / \binom{k}{2} = 2N \bigl(\tfrac{1}{k-1} - \tfrac{1}{k}\bigr)$ generations. Summing from $k = N$ down to $k = 2$, the terms telescope to $2N(1 - 1/N)$.

The approximation is good only once $k$ is well below $\sqrt{N}$. With many lines, several mergers happen in one generation, and for $k = 50$ the expression $\binom{k}{2}/N = 24.5$ is not even a probability. Those stages are short, though, so the total is hardly affected. The script computes the exact mean for this model from the exact probabilities that $k$ lines have $j$ distinct parents. It is 96.97 generations, one less than the approximation, with a standard deviation of 53.2.

Neutral, uniform crossover. With each bit of a child taken from one of two random parents, the 20 loci drift almost independently. The population still became uniform in every run, after a median of 199.5 generations (interquartile range 183 to 219).

Example (drift under two selection schemes). Now make every 1 the right allele: OneMax on strings of length 100, uniform crossover, still no mutation. Fitness-proportional selection leaves far more loci stuck at the wrong allele than binary tournament selection does. Under fitness-proportional selection, every run converged to a single string, after a median of 253 generations, and a median of 30 of the 100 loci were fixed at the wrong allele (interquartile range 28 to 33). No run found the optimum. Under binary tournament selection the population converged in a median of 35 generations with a median of 2 wrong loci (interquartile range 1 to 2), and 5 of 30 runs found the optimum.

The rule of thumb explains the difference. Under fitness-proportional selection, carrying a 1 at one locus adds 1 to a fitness of about 50 to 70. That is a relative advantage of about $1/50$ to $1/70$, no larger than $1/N = 0.02$. Each locus is close to neutral, and drift fixes many of them at 0 before selection can act. Tournament selection uses only comparisons, so a one-bit difference decides any contest between two individuals that are otherwise tied, however large their fitness values are.

Part of what EA practitioners call premature convergence is drift, not too much selection. The population loses alleles by chance, and without mutation nothing can bring them back. The usual remedies are mutation, larger populations, and diversity-preserving schemes such as island models and speciation.

The modern synthesis

Selection, heredity, variation and drift were not always seen as one theory. Mendelian genetics and Darwinian selection at first looked like rivals. Early Mendelians saw discrete mutations, not gradual selection, as the driver of change. Between about 1918 and 1932, Ronald Fisher, Sewall Wright, and J. B. S. Haldane showed mathematically that Mendelian inheritance and selection on small differences are compatible, founding population genetics (Fisher, 1930; Wright, 1931).

In the following decade, naturalists and paleontologists brought evidence from their fields into the same framework. Julian Huxley's book named the result the modern synthesis (Huxley, 1942). Its core claims are these:

  • evolution is change in allele frequencies within populations;
  • the change is driven by mutation, recombination, selection, drift, and migration;
  • the large differences between species accumulate from these small changes over long periods.

Classical EAs sit squarely inside this picture. A genetic algorithm is a population-genetics model with a chosen fitness function: a fixed population of haploid genotypes, allele frequencies changed by selection and drift, and new variation supplied by mutation and recombination. Wright's image of populations moving across a surface of fitness values became the fitness landscape that EA researchers use to reason about difficulty. Later developments in biology have had less influence on mainstream EAs, though each has inspired research directions. Examples are the neutral theory, the role of development in shaping which variants can arise, and the genomics of gene regulation.

Summary: what an EA keeps, simplifies, and discards

Biology In a typical EA Status
Variation, differential fitness, heritability Population, selection operator, copying with variation Kept
Fitness as realized reproductive success, relative and environment-dependent Explicit fitness function, fixed for the run, scored per candidate Replaced
Variable population size, overlapping generations Fixed size; generational or steady-state replacement Simplified
Diploid genotypes, dominance One haploid string per individual Simplified
Development from genotype to phenotype Direct decoding; indirect encodings are the exception Mostly discarded
Mutation random with respect to effect, about $10^{-8}$ per site Designed operators, typically one change per offspring, sometimes self-adapted Changed
Recombination of aligned chromosomes in meiosis Crossover of any kind, any number of parents, or none Generalized
Acquired traits not inherited Lamarckian writing-back allowed in memetic algorithms Optional
Genetic drift Present and strong, since populations are small Kept, usually unintentionally
Changing environment, coevolving species Fixed objective, except in coevolutionary algorithms Discarded by default

Eiben and Smith (2015, ch. 2) summarize the borrowed analogy as a correspondence between natural evolution and problem solving: environment to problem, individual to candidate solution, fitness to quality. The table shows how much each side of that correspondence has been reshaped. What remains is the logic Lewontin identified, applied to a population that the designer sizes, scores, and controls.

What we have learned

Natural selection needs only Lewontin's three conditions, and an EA keeps all three. Almost everything else is reshaped. Fitness becomes a fixed score instead of realized reproductive success, and the genotype is decoded directly instead of developing. A typical mutation rate is nearly a million times the human rate per site. The arithmetic carried over intact: the haploid recursion, the breeder's equation and the diffusion formula all predicted the script's numbers. They also explained two practical facts about EAs. Noisy evaluation lowers the heritability of fitness, and in small populations drift can fix wrong alleles that weak selection cannot protect.

One consequence was flagged along the way. Natural selection makes a population change, not optimize, and an EA optimizes only because its designer fixes what fitness means. That limits how far the biological metaphor can be trusted as a guide to designing algorithms. The next article, the limits of the evolutionary metaphor, shows a model in which selection lowers mean fitness. It concludes that a metaphor is a reason to try an idea, not a reason to believe it works.

References

  • Darwin, C. (1859). On the Origin of Species by Means of Natural Selection, or the Preservation of Favoured Races in the Struggle for Life. John Murray. record
  • Eiben, A. E., and Smith, J. E. (2015). Introduction to Evolutionary Computing, 2nd ed., chapters 2, 3, 5, and 10. Springer. record · 35 pages
  • Fisher, R. A. (1930). The Genetical Theory of Natural Selection. Clarendon Press. record
  • Futuyma, D. J., and Kirkpatrick, M. (2017). Evolution, 4th ed. Sinauer Associates. record · 2 pages
  • Huxley, J. (1942). Evolution: The Modern Synthesis. George Allen and Unwin. record
  • Johannsen, W. (1911). The genotype conception of heredity. The American Naturalist, 45(531), 129–159. record
  • Kimura, M. (1962). On the probability of fixation of mutant genes in a population. Genetics, 47(6), 713–719. record
  • Kimura, M. (1968). Evolutionary rate at the molecular level. Nature, 217(5129), 624–626. record · 2 pages
  • Kong, A., Frigge, M. L., Masson, G., Besenbacher, S., Sulem, P., Magnusson, G., et al. (2012). Rate of de novo mutations and the importance of father's age to disease risk. Nature, 488(7412), 471–475. record
  • Lewontin, R. C. (1970). The units of selection. Annual Review of Ecology and Systematics, 1, 1–18. record · 2 pages
  • Mendel, G. (1866). Versuche über Pflanzen-Hybriden. Verhandlungen des naturforschenden Vereines in Brünn, 4, 3–47. record
  • Wright, S. (1931). Evolution in Mendelian populations. Genetics, 16(2), 97–159. record

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 8 revisions