Tutorials › Quantitative Systems Pharmacology (QSP) › Deriving Mean-Field Equations from Agent Rules

Spatial and Agent-Based Approaches · Tutorial 233 of 799

Deriving Mean-Field Equations from Agent Rules

Learn to translate agent interactions into deterministic population equations while recognizing the assumptions and approximations behind the mean-field limit.

Advanced 12 min read

What You'll Learn

  • Express agent events as state changes with corresponding propensities.
  • Derive conditional drift equations from event rules.
  • Distinguish deterministic mean-field equations from exact equations for stochastic expectations.
  • Scale count equations to fractions when population size is fixed.
  • Identify the correlation and spatial information discarded by mean-field closure.
  • Diagnose when a well-mixed deterministic approximation may be unreliable.

From Agent Rules to Population Equations

An agent model specifies what individuals can do and how likely each event is. A population equation describes how aggregate counts or fractions change over time. The bridge between them is systematic: represent each event by its change in counts and its propensity, then sum the expected changes contributed by all possible events.

The resulting drift is not automatically an exact equation for the average trajectory of a stochastic population. Nonlinear interactions make expected event rates depend on joint distributions, not just on average counts. A deterministic mean-field equation typically adds a closure approximation, such as treating interacting agents as independently mixed. Keeping these two steps distinct is essential when interpreting and checking a model.

Definition: Let \(X(t)\) be a vector of agent counts, with event types indexed by \(r\). Event \(r\) changes the state by a jump vector \(\nu_r\) and occurs with propensity \(a_r(x)\) when the current state is \(x\). The conditional drift at state \(x\) is the expected instantaneous change in the count vector: $$ b(x)=\sum_r \nu_r a_r(x). $$ For a continuous-time stochastic jump model, this is the conditional rate of change given the current state. It does not, in general, equal the rate of change of the expected state evaluated at its expectation.

A propensity is an event rate, not a probability. For example, if each of \(A\) agents independently converts at rate \(k\), the total conversion propensity is \(kA\). If a rule requires a pair of agents to interact, its propensity depends on the number of eligible pairs and on the convention for selecting those pairs. That convention must be stated, since it determines the rate constant and sometimes a factor of two.

Conditional Drift and Mean-Field Closure

For a continuous-time jump process, over a short interval of length \(\Delta t\), event \(r\) occurs with probability \(a_r(x)\Delta t+o(\Delta t)\), while the probability of two or more events is \(o(\Delta t)\). The expected state increment conditional on \(X(t)=x\) is therefore

$$ \mathbb{E}[X(t+\Delta t)-X(t)\mid X(t)=x] =\sum_r \nu_r a_r(x)\Delta t+o(\Delta t). $$

Dividing by \(\Delta t\) and taking the limit gives the conditional drift \(b(x)\). Taking expectations over the random state gives the exact first-moment equation

$$ \frac{d}{dt}\mathbb{E}[X(t)] =\mathbb{E}[b(X(t))] =\sum_r \nu_r\mathbb{E}[a_r(X(t))]. $$

The equation is exact when the required expectations exist, but it may not be closed: its right-hand side can involve second moments or joint moments not specified by the mean state. A deterministic mean-field model instead uses population-scale variables and approximates these event rates by functions of their average densities. For pair interactions, this commonly amounts to replacing a pair density by the product of the two single-agent densities. This assumes sufficiently weak correlations and sufficiently extensive mixing; it is an approximation, not an identity for a finite stochastic system.

Key distinction: The equation \(\dot{x}=b(x)\) is a deterministic drift or mean-field equation when \(x\) is treated as a continuous population state. For a stochastic process, the exact mean equation is \(\frac{d}{dt}\mathbb{E}[X]=\mathbb{E}[b(X)]\). Replacing the latter by \(b(\mathbb{E}[X])\) requires justification or an explicit closure approximation.

Worked Example: Two-State Conversion

Suppose a fixed population of \(N=100\) agents is in state A or state B. Each A agent converts to B at rate \(k_{AB}=0.20\) per day, and each B agent converts to A at rate \(k_{BA}=0.10\) per day. Derive the count equations and calculate their initial drift when \(A=60\) and \(B=40\).

The event A to B has jump vector \((-1,+1)\) and propensity \(0.20A\). The event B to A has jump vector \((+1,-1)\) and propensity \(0.10B\). Summing jump vectors times propensities gives

$$ \begin{aligned} \dot A&=-0.20A+0.10B,\\ \dot B&=0.20A-0.10B. \end{aligned} $$

At \(A=60\), the first event rate is \(0.20(60)=12\) conversions per day; at \(B=40\), the reverse rate is \(0.10(40)=4\) conversions per day. Thus the conditional drifts are \(\dot A=-12+4=-8\) agents per day and \(\dot B=12-4=8\) agents per day. Their sum is zero, as it must be for a fixed population in which every event changes one A into one B or vice versa.

Here the exact expected count equations also close: propensities are linear in the counts, so \(\mathbb{E}[0.20A]=0.20\mathbb{E}[A]\), and likewise for B. The sample paths remain stochastic, but the equations for their expected counts have the same linear form.

Scaling Counts to Fractions

If the total population \(N\) is fixed, define fractions \(s=S/N\), \(i=I/N\), or more generally \(z=x/N\). When event propensities scale as \(a_r(x)=N\alpha_r(z)\), the deterministic count drift satisfies \(\dot{x}=\sum_r \nu_r N\alpha_r(z)\). Dividing by the constant \(N\) gives the fraction equation

$$ \dot z=\sum_r \nu_r\alpha_r(z). $$

The fixed-population condition matters. If \(N\) changes in a deterministic population description, differentiating \(z=x/N\) gives

$$ \dot z=\frac{1}{N}\dot x-\frac{x}{N^2}\dot N. $$

The second term accounts for dilution or concentration of the fraction as the total population changes. In an agent model, \(\dot N\) must be obtained from the population changes caused by the event rules; it cannot be assumed to vanish when births or deaths occur. For a finite stochastic process, fractions can also jump when an event changes the denominator, so an exact stochastic fraction drift should be computed from the event-by-event changes in \(x/N\), rather than inferred by treating a random denominator as constant.

Worked Example: Infection and Recovery in a Fixed Population

Consider a well-mixed population with susceptible count \(S\), infectious count \(I\), and fixed total \(N=S+I=1000\). Each susceptible agent becomes infected through contact with an infectious agent, with total infection propensity \(\beta SI/N\), where \(\beta=0.40\) per day. Each infectious agent recovers at rate \(\gamma=0.10\) per day. Derive the fraction equations and the initial mean-field drift for \(S=800\) and \(I=200\).

Infection changes the counts by \((-1,+1)\), and recovery changes them by \((+1,-1)\). Their propensities are \(\beta SI/N\) and \(\gamma I\), respectively. The deterministic count drift is therefore

$$ \dot S=-\beta\frac{SI}{N}+\gamma I,\qquad \dot I=\beta\frac{SI}{N}-\gamma I. $$

Since \(N\) is fixed, define \(s=S/N\) and \(i=I/N\). Then \(SI/N=Nsi\), so division of both count equations by \(N\) yields

$$ \dot s=-\beta si+\gamma i,\qquad \dot i=\beta si-\gamma i. $$

Initially \(s=800/1000=0.800\) and \(i=200/1000=0.200\). The infection rate is \(0.40(800)(200)/1000=64\) infections per day, and the recovery rate is \(0.10(200)=20\) recoveries per day. Thus \(\dot S=-64+20=-44\) agents per day and \(\dot I=64-20=44\) agents per day. In fractions, \(\dot s=-44/1000=-0.0440\) per day and \(\dot i=0.0440\) per day.

The mixing assumption is encoded in the infection propensity: each susceptible has an infection hazard proportional to the infectious fraction \(I/N\). In a finite stochastic model, the exact mean equation contains \(\mathbb{E}[SI]\), not necessarily \(\mathbb{E}[S]\mathbb{E}[I]\). The displayed fraction equations are the deterministic well-mixed mean-field model; they are not an exact identity for stochastic expected fractions in every finite population.

What Pair Interactions Leave Out

A well-mixed pair propensity replaces the actual local opportunities for interaction by a count-based approximation. On a lattice, for example, infection may occur only when a susceptible and an infectious agent occupy neighboring sites. The total infection rate then depends on the number of susceptible-infectious neighboring pairs, not merely on the product \(SI/N\). If infectious agents cluster, or if susceptible agents are excluded from infected neighborhoods, the number of eligible pairs can differ substantially from the well-mixed prediction.

Even without explicit space, nonlinear propensities create statistical dependence. For infection, the exact first-moment equation is

$$ \frac{d}{dt}\mathbb{E}[I] =\frac{\beta}{N}\mathbb{E}[SI]-\gamma\mathbb{E}[I]. $$

Writing \(\mathbb{E}[SI]=\mathbb{E}[S]\mathbb{E}[I]+\operatorname{Cov}(S,I)\) shows exactly what is discarded when the pair count is replaced by a product of average counts: the covariance term. In spatial models, additional information is needed about which agents are neighbors and how local arrangements evolve. A pair approximation attempts to retain some pair-level information; spatial agent models retain explicit positions and local interactions. Each adds detail and cost beyond a single well-mixed population equation.

Worked Example: Birth, Death, and Pairwise Competition

Let \(N\) be a variable population count. Births add one agent at propensity \(rN\), deaths remove one at propensity \(dN\), and competition removes one agent at propensity \(cN(N-1)/K\). Use \(r=0.30\) per day, \(d=0.10\) per day, \(c=0.50\) per day, and \(K=1000\). Find the conditional drift at \(N=100\), then state the exact mean equation and a large-population mean-field approximation.

The jump sizes are \(+1\), \(-1\), and \(-1\). Multiplying each by its propensity gives the conditional drift at a current count \(N\):

$$ b(N)=rN-dN-\frac{cN(N-1)}{K}. $$

At \(N=100\), the birth rate is \(0.30(100)=30\) agents per day, the death rate is \(0.10(100)=10\) agents per day, and the competition rate is \(0.50(100)(99)/1000=4.95\) events per day. Thus \(b(100)=30-10-4.95=15.05\) agents per day. This is the instantaneous conditional drift at the specified state, not a claim that the exact stochastic mean always changes at a rate given by substituting its mean count into \(b\).

For a stochastic population, the exact mean equation is

$$ \frac{d}{dt}\mathbb{E}[N] =(r-d)\mathbb{E}[N]-\frac{c}{K}\mathbb{E}[N(N-1)]. $$

It is generally not closed in \(m=\mathbb{E}[N]\), because \(\mathbb{E}[N(N-1)]=m^2-m+\operatorname{Var}(N)\). A common large-population deterministic approximation replaces the count interaction by its leading quadratic term and evolves a continuous count \(n\) according to \(\dot n=(r-d)n-cn^2/K\). At \(n=100\), this gives \(0.20(100)-0.50(100)^2/1000=15.0\) agents per day, close to the conditional drift \(15.05\). The difference here is the finite-count distinction between \(N(N-1)\) and \(N^2\); stochastic variability adds a further difference between the exact mean equation and a closed mean-field equation.

Assumptions, Diagnostics, and Alternatives

A mean-field equation is most defensible when event rules are well specified, population sizes are large enough that individual jumps are small relative to the aggregate state, and the mixing or weak-correlation assumption behind each interaction term is plausible. If events conserve a quantity, the derived equations should preserve it. For example, a conversion between two states must leave their total count unchanged. If an event changes population size, the total-count equation must reflect that change.

Useful checks include:

  • Check event bookkeeping. For every event, verify that its jump vector matches the rule and that its propensity counts only eligible events.
  • Check units. A propensity has units of events per time; each count drift has units of agents per time, and each fraction drift has units of inverse time.
  • Check invariants and boundaries. Counts should not become negative under the event rules, conserved totals should remain conserved, and deterministic flows should point into the biologically feasible region at its boundaries.
  • Check mixing. Compare predictions with simulations or spatial reasoning when contacts are local, agents cluster, or interactions depend on neighborhood composition.
  • Check closure. If exact moment equations involve covariances or higher moments, state the approximation used to close them rather than presenting it as exact.

A frequent failure is to derive a conditional drift correctly and then label it the exact equation for the stochastic mean. The correction is to apply expectation to the entire drift, \(\frac{d}{dt}\mathbb{E}[X]=\mathbb{E}[b(X)]\), and inspect whether the resulting moments close. Another common error is to divide count equations by a changing total population while treating that total as constant; the quotient rule adds the term involving \(\dot N\).

ApproachWhat it representsMain trade-off
Well-mixed mean-field ODEAggregate deterministic counts or fractions, with pair rates approximated from population densitiesEfficient, but omits stochastic variation and often correlations or spatial arrangement
Moment or pair approximationAggregate equations that retain selected variances, covariances, or pair frequenciesCaptures some dependence, but introduces additional equations and closure choices
Stochastic agent simulationIndividual event histories, with positions or identities retained as specified by the modelPreserves stochastic variation and chosen structure, but requires repeated simulation and careful interpretation

Mean-field equations are useful for understanding average directional behavior, identifying parameter combinations that govern population-level dynamics, and obtaining a compact model for analysis. They are limited when rare events matter, the population is small, contact structure is strongly heterogeneous, or correlations persist over the timescale of interest. In those settings, a deterministic solution may still be a useful reference, but agreement with it should not be assumed simply because the agent rules have been translated correctly.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A fixed population has \(A\to B\) at rate \(kA\) and \(B\to A\) at rate \(hB\). What is the drift of \(A+B\)?
  2. For a pairwise event with propensity \(\beta SI/N\), why is the exact infection contribution to the mean infectious-count equation not generally \(\beta\mathbb{E}[S]\mathbb{E}[I]/N\)?
  3. If the total population changes, what extra term appears when differentiating \(z=x/N\)?
  4. For a stochastic birth-death-competition process with drift \(b(N)=(r-d)N-cN(N-1)/K\), write the exact equation for \(d\mathbb{E}[N]/dt\).
  5. Name one condition under which a well-mixed pair propensity may misrepresent local interactions.

Solutions. (1) The A-to-B event contributes \(-kA\) to \(\dot A\) and \(+kA\) to \(\dot B\); the reverse event contributes \(+hB\) and \(-hB\). Therefore \(\dot A+\dot B=0\). (2) The exact contribution is \(\beta\mathbb{E}[SI]/N\); in general, \(\mathbb{E}[SI]=\mathbb{E}[S]\mathbb{E}[I]+\operatorname{Cov}(S,I)\), so the product of means omits the covariance. (3) The quotient rule gives \(\dot z=\dot x/N-x\dot N/N^2\). (4) Taking the expectation of the conditional drift gives \(\frac{d}{dt}\mathbb{E}[N]=(r-d)\mathbb{E}[N]-(c/K)\mathbb{E}[N(N-1)]\), which is not generally closed in the mean alone. (5) Clustering, spatially localized contacts, or heterogeneous neighbor counts can make the number of eligible local pairs differ from the well-mixed estimate.

Clinical Biostats