On conditioning a random process

November 14, 2026


A recent paper on B cell evolution in germinal centers1 led me to think about Doob's $h$-transform (Doob, 1957).

The $h$-transform formalizes a simple idea. Suppose we keep only the realizations of a random process that end in a particular way. These realizations still follow the original dynamics, except that they are biased toward that ending. The bias is set by $h$, the probability of the ending given where the process is now, and it enters as a correction to the deterministic term – so it can look a lot like selection (or drift, if you are a physicist2).

This matters because in evolution we often see only the realizations that end up in our data3, such as mutations that reached frequencies high enough to be detected. Unless we account for this, we can mistake the effect of conditioning for selection.


The transform

Let $f(t)$ be a Markov process, such as the frequency of an allele, and $E$ an event decided by its future, such as fixation. Let $h(f) = \Pr\big[E \mid f\big]$ be the probability of $E$ starting from $f$. Conditioning on $E$ and applying Bayes' rule to a single step $\Delta t$,

$ \displaystyle{ \Pr\big[f \to f{+}\Delta f \mid E\big] = \Pr\big[f \to f{+}\Delta f\big]\, \frac{h(f{+}\Delta f)}{h(f)} } $.

Steps toward states from which $E$ is likely are made more probable, and steps away from them less probable. The reweighting depends only on the current step, so the conditioned process is also Markov. The new probabilities still sum to one, because $h(f) = \langle h(f{+}\Delta f) \rangle$, with the average taken over the possible steps. This relation is an equation that one can solve to find fixation probabilities4.

The time evolution of $f(t)$ can be written as a Langevin equation,

$ \displaystyle{ \partial_t f = A(f) + \sqrt{B(f)}\, \eta(t) } $,

with the first term deterministic and the second stochastic, where $\eta(t)$ is uncorrelated noise with unit variance, interpreted in the Itô sense. Conditioning reweights each step $\Delta f$ by $h(f{+}\Delta f)/h(f) \approx 1 + \Delta f\, \partial_f \ln h$, so that, to leading order in $\Delta t$,

$ \displaystyle{ \langle \Delta f \mid E \rangle \approx \langle \Delta f \rangle + \langle \Delta f^2 \rangle\, \partial_f \ln h \approx \big( A + B\, \partial_f \ln h \big) \Delta t } $,

and the conditioned process becomes

$ \displaystyle{ \partial_t f = A(f) + B(f)\, \partial_f \ln h(f) + \sqrt{B(f)}\, \eta(t) } $.

Conditioning thus leaves the noise unchanged and adds a deterministic term, $B\, \partial_f \ln h$, that points toward where $E$ is more likely. The term is a product of how much the steps vary and how strongly the conditioning prefers one direction over another: without noise there is nothing to choose between, however strong the preference.

For a mutation with selection coefficient $s$, conditioning on fixation4 gives an apparent selection coefficient $s \coth(Nsf) > s$. Mutations that fix therefore rise faster than expected early on (Maynard Smith and Haigh, 1974; Otto and Barton, 1997), and in lineage-tracking experiments can appear to have established before they arose (Levy, Blundell, et al., 2015).


At a finite time

Most observations condition on something weaker than ultimate fixation: a mutation only has to be present at some time $T$. The probability of this now depends on time,

$ \displaystyle{ h_T(f, t) = \Pr\big[ f(T) > 0 \mid f(t) = f \big] } $.

While the mutation is rare, its dynamics are linear, with descendants surviving to $T$ independently. The chance that at least one of them survives is then proportional to the frequency of the mutation, so $h_T \propto f$ and $\partial_f \ln h_T = 1/f$. Substituting $B(f) \approx f/N$5 gives a correction of

$ \displaystyle{ B(f)\, \partial_f \ln h_T \approx 1/N } $,

so a lineage that will be present at $T$ gets there by gaining one extra copy per generation. A neutral lineage that survives for $t$ generations therefore has a frequency of ${\sim}t/N$ (Desai and Fisher, 2007). The climb lasts until the mutation is large enough that it would almost certainly be present at $T$ anyway, which is at $Nf \sim T - t$. This linear growth comes entirely from conditioning – not selection – and the unconditioned average stays constant. The same reasoning, applied to the Laplace transform of $f(T)$, yields the full frequency distribution of a surviving lineage, which is exponential with mean ${\sim}(T - t)/N$, as first found by Kendall (1948).

The same conditioning, applied to the frequencies seen at several sampling times, can be used to infer selection from temporal data (Schraiber, Griffiths, and Evans, 2013; Schraiber, Evans, and Slatkin, 2016).


Feynman–Kac weighting

Imagine now that, as the lineage grows, it accumulates further mutations elsewhere on the genome that change its fitness. Its weight then builds up along the way, rather than being set by its fate at time $T$. Following the fitness $x(t)$ of the lineage, relative to the population mean, and weighting each path by its compound growth, gives the expected number of descendants,

$ \displaystyle{ h_T(x, t) = \Big\langle e^{\int_t^T x(u)\, du} \,\Big|\, x(t) = x \Big\rangle } $.

This is known as the Feynman–Kac formula (Kac, 1949). The correction is again $B(x)\, \partial_x \ln h_T$.

Mutations that leave more descendants thus tend to arise on unusually fit backgrounds, an idea that runs through much of the theory of linked selection (e.g., Desai and Fisher, 2007; Cvijović, Good, and Desai, 2018).


Back to germinal centers

The genealogies of sampled B cells are conditioned in just this way. Far from the time of sampling, conditioning favors lineages with high affinity, so affinity appears to rise quickly early on; close to it, the correction fades and low-affinity cells that have not yet been removed still appear, so affinity appears to plateau. Neither pattern requires selection to change over time.




1 DeWitt et al. (2026) argue that two features of B cell genealogies reconstructed from germinal centers – affinity increasing quickly early on and then plateauing, and low-affinity lineages persisting for a long time – do not mean that selection weakens over time. Instead, both arise because the genealogies contain only the ancestors of cells sampled at the end.

2 In physics, the deterministic term of a stochastic differential equation is called the drift and the noise term the diffusion. In population genetics, drift refers to the noise, and the deterministic term is usually selection. I use the population genetics convention throughout.

3 A classic example is phylogenies of extant species. A reconstructed tree contains only lineages that left descendants in the present, so lineages that went extinct are missing from it. Nee, May, and Harvey (1994) showed that, as a result, the number of lineages through time bends upward toward the present even when speciation and extinction rates are constant: recent lineages have not yet had time to go extinct.

4 A mutation fixes when it reaches frequency one, so that every individual in the population carries it. For a mutation with selection coefficient $s$ in a population of size $N$, solving this relation with absorbing boundary conditions, $h(0) = 0$ and $h(1) = 1$, gives the fixation probability $h(f) = (1 - e^{-2Nsf})/(1 - e^{-2Ns})$, as derived by Kimura (1962). For a new beneficial mutation in a large population, $h \approx 2s$, as first found by Haldane (1927).

Conditioning on fixation with this $h$ gives $\partial_t f = s f(1-f) \coth(Nsf) + \sqrt{f(1-f)/N}\, \eta(t)$. The deterministic term is even in $s$, so a deleterious mutation that fixes follows the same dynamics as a beneficial one (this is known as Maruyama's symmetry; Maruyama, 1974).

5 For a mutation with selection coefficient $s$ in a population of size $N$, the frequency follows $\partial_t f = s f(1-f) + \sqrt{f(1-f)/N}\, \eta(t)$. When $f \ll 1$, the factors of $1 - f$ can be dropped, and this becomes the linear branching process $\partial_t f = s f + \sqrt{f/N}\, \eta(t)$, with $A(f) \approx s f$ and $B(f) \approx f/N$.