2  Stochastic Models of Gene Expression

2.1 An Experimental Puzzle: The Ubiquity of Noise

In the last chapter, we developed a powerful framework for modeling gene circuits using the world of averages. But what happens when we can actually look inside an individual cell and count the molecules one by one?

A very nice experiment in 2006 (Raj et al. 2006) did just that. They engineered mammalian cells in a way that let them count the exact number of mRNA molecules for a specific gene in hundreds of individual cells. If our deterministic models were the whole story, we would expect every genetically identical cell, living in the same uniform environment, to have the same number of mRNAs.

The reality was strikingly different.

Figure 2.1: Experimental evidence for noise in gene expression. Single-molecule fluorescence in situ hybridization (smFISH) reveals the wide distribution of mRNA copy numbers in a population of genetically identical mammalian cells. Panel A shows individual cells with varying numbers of fluorescent spots (each spot represents a single mRNA molecule). Panel B shows the distribution of mRNA counts across the population, revealing substantial cell-to-cell variability despite identical genotypes and environments. Data from Raj et al. (2006).

Instead of a single value, they observed a wide distribution of mRNA counts. Some cells had very few, some had many, and most were somewhere in between. This variability, or noise, is not a measurement error; it is a fundamental feature of life at the molecular level. This experiment poses a key question: if the DNA blueprint is the same, why is there so much variation in its execution?

This is not an isolated phenomenon. Similar variability has been observed in many systems, including bacteria and yeast. Crucially, this molecular variability leads to phenotypic variability, which can have significant implications for cell populations—from antibiotic resistance in bacteria to cell fate decisions in development.

To make sense of this rampant variability, we must first learn how to classify it. What are its fundamental sources?

2.2 Separating Noise: The Two-Color Experiment

The first step in taming this randomness is to understand its origins. “Noise” is not a monolith; it’s a combination of two fundamentally different sources, a distinction first clarified in a landmark 2002 study (Elowitz et al. 2002).

Intrinsic noise is the randomness baked into the molecular hardware of the cell. It’s the irreducible uncertainty that arises because chemical reactions are probabilistic events. Even in a perfectly constant environment, the birth and death of individual mRNA and protein molecules would occur at random moments, causing their numbers to fluctuate. This is the noise that comes from the machinery of life itself—the dice rolls of transcription and translation.

Extrinsic noise is variability that comes from outside the specific genetic circuit we’re studying. It’s caused by fluctuations in the cellular environment that affect all genes in a cell. Two “identical” cells are never truly identical. One might be slightly larger, have more ribosomes, be in a different phase of the cell cycle, or have a different metabolic state. These differences create cell-to-cell variation in a correlated way.

Imagine two identical, perfectly balanced roulette wheels. The randomness of each spin is like intrinsic noise—each wheel’s outcome is independent. Now, imagine both wheels are on a table that is being gently shaken. The shaking is like extrinsic noise—it adds a correlated layer of variability to both wheels simultaneously.

This distinction would be purely academic if we couldn’t measure it. How can we possibly separate these two sources of noise in a living cell? The genius of the Elowitz experiment was to design a system that could do exactly that: the two-color reporter experiment.

The approach is straightforward yet powerful: 1. Build two identical reporters: They took two copies of the same promoter and used them to drive the expression of two different fluorescent proteins—one cyan (CFP) and one yellow (YFP). 2. Put them in the same cell: Both reporter genes were integrated into the E. coli chromosome, so they would experience the exact same cellular environment. They are both on the same shaky table. 3. Measure and compare: By measuring the amount of CFP and YFP in many individual cells, they could dissect the sources of noise.

Figure 2.2: The two-color reporter experiment design. Panel A shows fluorescence traces over time for two identical reporters (cyan and yellow fluorescent proteins) driven by the same promoter. Panel B shows the experimental setup: both reporter genes experience the same cellular environment but have independent intrinsic noise. The microscopy image shows E. coli cells expressing both reporters, allowing quantitative separation of intrinsic and extrinsic noise sources. From Elowitz et al. (2002).

Here’s the logic. Because both genes share the same cellular environment, any fluctuation in that environment (e.g., a change in the number of RNA polymerase molecules) will affect both promoters simultaneously. This is the extrinsic noise, and it creates a positive correlation between the two signals. If the cell has more polymerase, both CFP and YFP expression will go up together.

Intrinsic noise, however, is unique to each gene. The random timing of a polymerase binding to the CFP promoter is an independent event from a polymerase binding to the YFP promoter. The CFP gene doesn’t “know” when the YFP gene fires. This creates uncorrelated fluctuations between the two signals.

This experimental design allows us to use simple statistics to pull apart the noise. Let’s say we measure the expression of the two reporters, which we’ll call C (for cyan) and Y (for yellow), across a population of cells.

Extrinsic noise is quantified by the covariance between the two reporters:

\eta_{\text{extrinsic}}^2 = \frac{\text{Cov}(C, Y)}{\langle C \rangle \langle Y \rangle}

Because intrinsic noise sources are independent, they average out to zero when computing covariance. Only shared, extrinsic fluctuations contribute.

Intrinsic noise measures how much the two identical reporters differ:

\eta_{\text{intrinsic}}^2 = \frac{\langle(C-Y)^2\rangle}{2\langle C \rangle \langle Y \rangle}

Total noise accounts for variability in both reporters:

\eta_{\text{total}}^2 = \frac{\langle C^2 \rangle + \langle Y^2 \rangle - 2\langle C \rangle \langle Y \rangle}{2\langle C \rangle \langle Y \rangle}

These satisfy: \eta_{\text{total}}^2 = \eta_{\text{intrinsic}}^2 + \eta_{\text{extrinsic}}^2.

Note: Earlier versions of these notes used a simpler approach: defining \eta_{\text{total}}^2 = \text{Var}(C)/\langle C \rangle^2 and deriving \eta_{\text{intrinsic}}^2 by subtraction. This is mathematically equivalent to our current formulation when the reporters are truly identical (\langle C \rangle = \langle Y \rangle), but the present approach is more general and robust to experimental variations.

This decomposition allows us to quantify the contribution of each noise source. The Elowitz experiment found that both were significant, proving that the randomness inherent to gene expression is a fundamental and inescapable property of life.

Figure 2.3: Quantitative separation of intrinsic and extrinsic noise. Panel (a) shows the correlation between two identical reporters (CFP vs YFP fluorescence) in individual cells. The scatter reveals both correlated variation (extrinsic noise, indicated by the diagonal trend) and uncorrelated variation (intrinsic noise, indicated by scatter around the diagonal). Panel (b) shows the decomposition of total noise (η_tot) into its intrinsic (η_int) and extrinsic (η_ext) components across different fluorescence levels, demonstrating that both sources contribute significantly to overall expression variability. From Elowitz et al. (2002).

Having established that noise is central to gene expression and developed tools to quantify it, we now face a deeper challenge: how do we build mathematical models that can predict this randomness? This requires us to abandon the familiar world of concentrations and embrace the probabilistic world of discrete molecules—a journey that leads us to the Chemical Master Equation.


2.3 A Probabilistic Foundation: The Chemical Master Equation

In the previous section, we established that deterministic models have fundamental limitations. They predict a single, continuous concentration value, but they have no concept of noise, randomness, or the integer nature of molecules. This forces us to ask a deeper question. Instead of asking “What is the concentration of protein X at time t?”, we must ask:

What is the probability of having exactly n molecules of protein X at time t?

This shift from a certain world of continuous values to an uncertain world of discrete probabilities is the conceptual leap we need to make. The tool that allows us to navigate this new world is the Chemical Master Equation (CME).

2.3.1 From Continuous to Discrete: The Fundamental Question

Let’s return to the simplest possible model of gene expression from Chapter 1: the constitutive gene.

\frac{dx}{dt} = \beta - \gamma x

Here, \beta is the constant rate of production and \gamma is the per-molecule rate of degradation. The steady-state concentration is simply x_{ss} = \beta / \gamma.

Figure 2.4: A simple diagram showing a gene producing a protein at a constant rate, which is then degraded or diluted.

To translate this into a probabilistic framework, we consider two fundamental reactions:

  1. Production: A new molecule is created. ∅ -> X. This happens at a constant rate, \beta.
  2. Degradation: An existing molecule is destroyed. X -> ∅. The rate of this reaction depends on how many molecules exist. If there are n molecules, the total degradation rate is \gamma n.

Our goal is to find P(n, t), the probability of having exactly n molecules at time t. This probability distribution P(n,t) is our new fundamental object—it contains all the information about the system’s behavior.

2.3.2 Deriving the CME for the Constitutive Gene

How does this probability change? It changes by molecules being made or destroyed. We can think of this as simple bookkeeping. The change in the probability of being in state n is the sum of the probability fluxes into state n minus the sum of the probability fluxes out of state n.

\frac{dP(n,t)}{dt} = (\text{Flux into } n) - (\text{Flux out of } n)

Let’s build the equation term by term.

How can we get to state n?

  • By Production: We were in state n-1 and one molecule was produced. The probability of this happening is the probability of being in state n-1, which is P(n-1, t), times the rate of production, \beta.
    • Flux in from production: \beta P(n-1, t)
  • By Degradation: We were in state n+1 and one molecule was degraded. The probability of this is the probability of being in state n+1, P(n+1, t), times the total degradation rate for n+1 molecules, which is \gamma(n+1).
    • Flux in from degradation: \gamma(n+1)P(n+1, t)

How can we get out of state n?

  • By Production: We are in state n and one more molecule is produced, moving us to state n+1. The rate of this is simply \beta.
    • Flux out by production: \beta P(n, t)
  • By Degradation: We are in state n and one molecule is degraded, moving us to state n-1. The rate of this is \gamma n.
    • Flux out by degradation: \gamma n P(n, t)

Putting it all together, we arrive at the Chemical Master Equation for constitutive gene expression:

\frac{dP(n, t)}{dt} = \underbrace{\beta P(n-1, t) + \gamma(n+1)P(n+1, t)}_{\text{Flux In}} - \underbrace{(\beta + \gamma n)P(n, t)}_{\text{Flux Out}}

This equation is actually an infinite set of coupled, linear ODEs—one for each possible value of n=0, 1, 2, .... While it looks intimidating, it’s just a precise accounting of probability flow.

Beyond the Constitutive Gene: The General Framework

The Chemical Master Equation provides a general framework for any system of chemical reactions. For a system with reactions:

R_1: \quad \text{species} \xrightarrow{k_1} \text{products} R_2: \quad \text{species} \xrightarrow{k_2} \text{products} \vdots

The general CME takes the form:

\frac{dP(\mathbf{n},t)}{dt} = \sum_{j} \left[ a_j(\mathbf{n} - \boldsymbol{\nu}_j) P(\mathbf{n} - \boldsymbol{\nu}_j, t) - a_j(\mathbf{n}) P(\mathbf{n}, t) \right]

where:

  • \mathbf{n} = (n_1, n_2, \ldots) is the state vector giving the number of molecules of each species
  • a_j(\mathbf{n}) is the propensity function for reaction j—the probability per unit time that reaction j occurs given state \mathbf{n}
  • \boldsymbol{\nu}_j is the stoichiometric vector for reaction j—how the state changes when reaction j occurs

2.3.3 The Steady-State Solution: Enter the Poisson

Now, returning to our specific constitutive gene model, solving the full time-dependent CME is often difficult. However, we can find the steady-state solution by setting the time derivative to zero: \frac{dP(n, t)}{dt} = 0. This gives us a recurrence relation that we can solve. The solution, as we will see, is the famous Poisson distribution.

Setting dP(n,t)/dt = 0 in our CME:

\beta P(n-1) + \gamma(n+1)P(n+1) = (\beta + \gamma n)P(n)

We can rearrange this to get a step-by-step recipe for computing each probability:

For n=0: \beta P(0) = \gamma P(1), so P(1) = \frac{\beta}{\gamma}P(0)

For n=1: \beta P(0) + 2\gamma P(2) = (\beta + \gamma)P(1)

Substituting P(1) and solving: P(2) = \frac{1}{2!}\left(\frac{\beta}{\gamma}\right)^2 P(0)

Continuing this pattern, we find:

P(n) = \frac{1}{n!}\left(\frac{\beta}{\gamma}\right)^n P(0)

Since all probabilities must sum to one, \sum_{n=0}^{\infty} P(n) = 1:

P(0) \sum_{n=0}^{\infty} \frac{1}{n!}\left(\frac{\beta}{\gamma}\right)^n = P(0) e^{\beta/\gamma} = 1

Therefore P(0) = e^{-\beta/\gamma}, and the complete solution is:

\boxed{P(n) = \frac{(\beta/\gamma)^n}{n!} e^{-\beta/\gamma}}

This is a Poisson distribution with parameter \lambda = \beta/\gamma!

This is a fundamental result that connects the deterministic and stochastic worlds. The average quantity of the stochastic system is exactly the steady state of the deterministic system. But the CME gives us so much more: it gives us the full probability distribution around that average. It tells us not just the destination, but the entire landscape of possibilities.

2.3.4 Connecting Stochastic and Deterministic Models

The Poisson result directly connects our stochastic and deterministic descriptions:

  • Mean: \langle n \rangle = \beta/\gamma (exactly matches the ODE steady state!)
  • Variance: \text{Var}(n) = \beta/\gamma (equals the mean, as characteristic of Poisson)
  • Coefficient of Variation: CV = \sqrt{\text{Var}}/\langle n \rangle = 1/\sqrt{\beta/\gamma}

The coefficient of variation reveals why stochasticity matters most at low copy numbers. When \beta/\gamma = 1 (one protein on average), CV = 100\%—the fluctuations are as large as the mean! But when \beta/\gamma = 100, CV = 10\%—the system behaves nearly deterministically.

2.3.5 Code: Visualizing the Poisson World

Let’s see what this looks like. We’ll plot the Poisson probability distribution for several different mean values (\lambda). This shows us how likely we are to observe a certain number of molecules in a cell for different average expression levels.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

# Different mean expression levels (using beta/gamma values)
lambda_values = [1, 5, 20, 50]
colors = [QUALITATIVE_COLORS[0], QUALITATIVE_COLORS[1], QUALITATIVE_COLORS[2], QUALITATIVE_COLORS[3]]  # red, blue, purple, yellow

fig, (ax1, ax2) = plt.subplots(1, 2)

# Panel A: Probability distributions
for lam, color in zip(lambda_values, colors):
    # Generate Poisson distribution
    n_vals = np.arange(0, max(80, lam + 4*np.sqrt(lam)))
    probs = poisson.pmf(n_vals, lam)
    
    # Plot as connected points
    ax1.plot(n_vals, probs, 'o-', color=color, linewidth=2, markersize=4,
             label=f'λ = {lam} (CV = {1/np.sqrt(lam):.2f})')

ax1.set_xlabel('Number of Molecules (n)')
ax1.set_ylabel('Probability P(n)')
ax1.set_title('(a) Poisson Distributions')
ax1.legend()
ax1.grid(True, alpha=0.3)
ax1.set_xlim(0, 80)

# Panel B: Coefficient of variation vs mean
lambda_range = np.logspace(0, 2, 100)
cv_theoretical = 1 / np.sqrt(lambda_range)

ax2.loglog(lambda_range, cv_theoretical, 'k-', linewidth=3, label='CV = 1/√λ')
ax2.scatter(lambda_values, [1/np.sqrt(lam) for lam in lambda_values], 
           s=80, c=colors, edgecolors='black', zorder=5)

ax2.set_xlabel('Mean Expression (λ = β/γ)')  
ax2.set_ylabel('Coefficient of Variation')
ax2.set_title('(b) Noise Decreases with Expression Level')
ax2.legend()
ax2.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()
Figure 2.5: Poisson distributions for constitutive gene expression at different mean levels. Panel (a) shows the probability distributions, demonstrating that higher mean expression leads to wider but relatively narrower distributions. Panel (b) shows the key biological insight: the coefficient of variation decreases as 1/√(mean), meaning noise is most significant at low copy numbers.

The coefficient of variation reveals why stochasticity matters most at low copy numbers. When \lambda = \beta/\gamma = 1 (one protein on average), CV = 100\%—the fluctuations are as large as the mean! But when \lambda = 100, CV = 10\%—the system behaves nearly deterministically. This explains a fundamental principle in biology: cells can reduce noise in gene expression simply by increasing expression levels. Critical regulatory proteins like transcription factors often exist at low copy numbers (high noise), making their regulation sensitive to molecular fluctuations. In contrast, abundant structural proteins like histones are expressed at high levels (low relative noise), ensuring consistent cellular architecture.

2.3.6 The Overdispersion Puzzle: Theory Meets Reality

We now have a rigorous theoretical prediction. Our simplest, most fundamental model—the constitutive gene—predicts that gene expression follows a Poisson distribution, where variance equals the mean. This is a precise, testable prediction. But when we confront this theory with experimental data, we encounter a striking failure.

When we examine gene expression in individual cells using single-cell RNA sequencing (scRNA-seq), we observe a systematic deviation from our Poisson prediction: the variance in expression is much larger than the mean. For most genes, if the mean expression level is \mu, the variance is not \mu (as predicted by Poisson) but rather something closer to \mu + \alpha\mu^2 for some \alpha > 0. This phenomenon is called overdispersion, and it reveals that our simple model is incomplete.

Figure 2.6: Experimental evidence for overdispersion in gene expression. Mean-variance relationship for RNA counts in mouse liver from MERFISH (blue) and scRNA-seq (orange) data, showing systematic deviations above the Poisson expectation (dashed line, variance = mean). Each point represents a gene with at least 50 cells expressing it. The inset shows the distribution of MERFISH RNA counts for Hmgcs2 (a liver hepatocyte marker), with a negative binomial fit (red line) that captures the overdispersion. This experimental evidence demonstrates that real gene expression exhibits variance much larger than the mean, invalidating our simple Poisson model and pointing toward the biological reality of transcriptional bursting. Data from Liu et al. (2022).

This systematic deviation is not experimental error—it’s a signature of the underlying biology. The quadratic scaling of the variance tells us something profound: the simple Poisson model misses a crucial aspect of how genes actually work. Our model assumes genes produce transcripts at a constant rate, but the overdispersion strongly suggests that the production process itself must be intermittent.

But is this just a convenient mathematical fiction, or is there direct experimental evidence for this intermittency? A 2006 experiment (Cai, Friedman, and Xie 2006) provided a nice clean answer.

Figure 2.7: Experimental evidence for transcriptional bursting and geometric burst size distribution. Panel (a) shows single-molecule detection of protein expression in individual yeast cells over time, revealing discrete bursts of production. Panel (b) shows the step-wise increase in protein number during individual bursts, with each step representing a single protein being produced. Panel (c) shows the distribution of burst sizes follows the predicted geometric distribution, confirming the theoretical model of transcriptional bursting. Data from Cai, Friedman, and Xie (2006).

The solution to the overdispersion puzzle lies in this more realistic view of how genes work, now directly supported by experimental evidence. As shown in Figure 2.7, real genes don’t just sit there churning out transcripts at a constant rate. Instead, they exist in discrete states—on and off—and they switch between these states randomly.

When a gene is in the “on” state, it transcribes rapidly. When it’s “off”, transcription stops entirely. This creates a bursty pattern: periods of intense transcriptional activity separated by quiet intervals. This phenomenon, called transcriptional bursting, is the biological mechanism that generates overdispersion.

This makes intuitive sense, and as we will see, it is easy to formulate as a model. The more difficult question is, how do we study such a model? Our simple Poisson derivation relied on analytically solving the Chemical Master Equation, but that becomes impossible for more complex systems. We need a new tool that allows us to simulate the exact stochastic trajectories of these more realistic, bursty models.


2.4 Simulating Reality: The Gillespie Algorithm

The Chemical Master Equation gives us the fundamental framework, but there’s a problem: for most systems, the CME is impossible to solve analytically. Even our simple constitutive gene required careful mathematical manipulation to find the Poisson solution. For more complex genetic circuits—with multiple genes, feedback loops, and nonlinear regulation—the CME quickly becomes intractable due to the “curse of dimensionality,” which necessitates the simulation-based approaches we will explore next.

This is where simulation comes to the rescue. If we can’t solve for the entire probability distribution, we can at least generate exact sample trajectories of how the system evolves over time. The Gillespie algorithm, developed by Dan Gillespie in 1976, provides a way to do exactly this: to simulate the stochastic evolution of a chemical reaction system with complete mathematical rigor.

The elegance of the Gillespie algorithm lies in how it reduces a complex, parallel problem into a simple, iterative procedure. At each step, it just has to answer two questions: (1) When does the next reaction happen? and (2) Which reaction is it? The mathematical framework below shows us how to answer both questions with statistical rigor.

2.4.1 The Mathematical Foundation: Memoryless Events and Exponential Waits

The rigor of the Gillespie algorithm is built on a deep connection between the probability of chemical reactions and the exponential distribution.

Let’s consider a single reaction that occurs with a constant probability per unit time, k. This rate k is often called the hazard rate. The crucial assumption is that this probability is constant in time; the reaction is just as likely to happen now as it is a second from now, regardless of how long we’ve been waiting. This is the memoryless property.

A process with a constant hazard rate has waiting times that are described by an exponential distribution. The probability density function for the waiting time T until the next event is given by:

f(t; k) = k e^{-kt}

The waiting time T is a random variable drawn from this distribution, which we write as T \sim \text{Exp}(k). The mean of this distribution is \langle T \rangle = 1/k. This is dimensionally consistent: if the rate k has units of events/time, the average waiting time has units of time/event. While notation varies, we define the exponential distribution by its rate parameter.

Let’s apply this to our constitutive gene model, which has two reactions:

  1. Production: ∅ -> X at rate β. This is a single reaction type with a constant rate. The waiting time for the next production event is thus an exponential random variable, t_{ ext{birth}} \sim \text{Exp}(\beta).

  2. Degradation: X -> ∅ at a per-molecule rate γ. If there are currently n molecules, there are n independent “targets” for degradation. The total rate of degradation is therefore nγ. The waiting time for the next degradation event is t_{\text{death}} \sim \text{Exp}(n\gamma).

2.4.2 The Core Theorem: Racing Exponential Clocks

Now we have two “competing” exponential processes. A birth could happen next, or a death could happen next. The system’s evolution depends on which event happens first. This leads us to the core mathematical theorem that underpins the Gillespie algorithm:

Theorem: If we have a set of independent exponential random variables T_1, T_2, \ldots, T_M with rates k_1, k_2, \ldots, k_M, then the time until the first event occurs, \tau = \min(T_1, T_2, \ldots, T_M), is also an exponential random variable with a rate equal to the sum of the individual rates:

\tau \sim \text{Exp}(k_1 + k_2 + \ldots + k_M)

Furthermore, the probability that event j is the one that occurs first is given by its relative contribution to the total rate:

P(\text{event } j \text{ is first}) = \frac{k_j}{\sum_{i=1}^M k_i}

Proof: The Gillespie Core Theorem

The time \tau = \min(T_1, \ldots, T_M) to the next event is exponentially distributed because its survival function P(\tau > t) is the product of the individual survival functions: P(\tau > t) = \prod_{i=1}^{M} P(T_i > t) = \prod_{i=1}^{M} e^{-k_i t} = e^{-(\sum k_i) t} This is the survival function for an exponential distribution with rate k_{\text{total}} = \sum k_i. The probability that reaction j is first is found by integrating its PDF against the survival of all other reactions: P(j \text{ is first}) = \int_0^\infty (k_j e^{-k_j t}) \left( \prod_{i \neq j} e^{-k_i t} \right) dt = \int_0^\infty k_j e^{-k_{\text{total}} t} dt = \frac{k_j}{k_{\text{total}}}

For our simple birth-death process, this means:

  • The time to the next reaction of any type is \tau = \min(t_{\text{birth}}, t_{\text{death}}), which is distributed as \tau \sim \text{Exp}(\beta + n\gamma).
  • The probability that this next reaction is a birth is P(\text{birth}) = \frac{\beta}{\beta + n\gamma}.
  • The probability that it is a death is P(\text{death}) = \frac{n\gamma}{\beta + n\gamma}.

This is a profound insight. It transforms the problem of simulating a complex system into a simple, iterative procedure: 1) Determine how long to wait for the next event by drawing from an exponential distribution whose rate is the sum of all possible reaction rates. 2) Decide which event happens by drawing from a discrete distribution weighted by the relative rates.

This event-driven approach is far more efficient and accurate than using a fixed time step dt. A fixed-step simulation would be inefficient if rates are low (many steps with no events) and inaccurate if rates are high (missing multiple events within one dt). The Gillespie algorithm addresses this by letting the system’s own kinetics determine the time scale.

2.4.3 The Algorithm: Two Random Numbers, Exact Results

The Gillespie algorithm turns these insights into a computational procedure:

Algorithm:

  1. Initialize: Set initial molecule counts \mathbf{n} and time t = 0.
  2. Compute propensities: For the current state \mathbf{n}, calculate the rate (propensity) a_j for each possible reaction j.
  3. Compute total propensity: Sum all propensities: a_{\text{total}} = \sum_j a_j. If a_{\text{total}} = 0, the simulation is finished.
  4. Generate waiting time: Draw a random number r_1 from a Uniform(0,1) distribution. The time to the next event, \tau, is calculated as: \tau = \frac{1}{a_{\text{total}}} \ln\left(\frac{1}{r_1}\right) This is equivalent to drawing from an \text{Exp}(a_{\text{total}}) distribution.
  5. Choose reaction: Draw a second random number r_2 from a Uniform(0,1) distribution. Find the reaction index \mu such that: \sum_{j=1}^{\mu-1} a_j < r_2 \cdot a_{\text{total}} \le \sum_{j=1}^{\mu} a_j This selects a reaction with probability proportional to its rate.
  6. Update state: Update the time t \leftarrow t + \tau and the molecule counts according to the stoichiometry of reaction \mu.
  7. Repeat: Go back to step 2.

This algorithm is mathematically exact—each trajectory it produces is a perfect sample from the probability distribution defined by the Chemical Master Equation. The beauty is that we avoid solving the CME entirely; we simply sample from it.

2.4.4 Code: Validating Against Theory

Let’s implement the Gillespie algorithm for our constitutive gene and verify that it reproduces the theoretical Poisson distribution we derived earlier.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def gillespie_constitutive(beta, gamma, t_final, n_initial=0):
    """
    Simulate constitutive gene expression using Gillespie algorithm
    
    Parameters:
    beta: production rate
    gamma: degradation rate per molecule
    t_final: simulation end time
    n_initial: initial number of molecules
    """
    # Initialize
    t = 0.0
    n = n_initial
    t_history = [t]
    n_history = [n]
    
    while t < t_final:
        # Compute propensities
        a_prod = beta          # production rate
        a_deg = gamma * n      # total degradation rate
        a_total = a_prod + a_deg
        
        # If no reactions possible, break
        if a_total == 0:
            break
            
        # Generate random numbers
        r1 = np.random.random()
        r2 = np.random.random()
        
        # Time until next reaction
        tau = -np.log(r1) / a_total
        
        # Which reaction occurs?
        if r2 * a_total < a_prod:
            # Production: n -> n+1
            n += 1
        else:
            # Degradation: n -> n-1
            n = max(0, n - 1)
        
        # Update time and record
        t += tau
        t_history.append(t)
        n_history.append(n)
    
    return np.array(t_history), np.array(n_history)

# Parameters matching our theory
beta = 10.0      # production rate
gamma = 0.5      # degradation rate per molecule
lambda_theory = beta / gamma  # theoretical mean = 20

# Generate sample trajectories
np.random.seed(42)
n_trajectories = 6
t_final = 10.0

fig, (ax1, ax2) = plt.subplots(1, 2)

# Panel (a): Sample trajectories
for i in range(n_trajectories):
    t_vals, n_vals = gillespie_constitutive(beta, gamma, t_final)
    ax1.step(t_vals, n_vals, where='post', color=QUALITATIVE_COLORS[i], alpha=0.8, linewidth=1.5)

ax1.set_xlabel('Time')
ax1.set_ylabel('Number of Molecules')
ax1.set_title('(a) Sample Trajectories')
ax1.grid(True, alpha=0.3)

# Panel (b): Steady-state distribution
n_simulations = 10000
final_counts = []

for i in range(n_simulations):
    t_vals, n_vals = gillespie_constitutive(beta, gamma, t_final)
    final_counts.append(n_vals[-1])  # final molecule count

# Plot histogram
ax2.hist(final_counts, bins=np.arange(0, 50), density=True, alpha=0.6,
         color='gray', edgecolor='none', label='Simulation')

# Overlay theoretical Poisson
n_range = np.arange(0, 50)
poisson_probs = poisson.pmf(n_range, lambda_theory)
ax2.plot(n_range, poisson_probs, 'o-', color=QUALITATIVE_COLORS[1], linewidth=2, markersize=4,
         label=f'Poisson (λ={lambda_theory:.1f})')

ax2.set_xlabel('Number of Molecules')
ax2.set_ylabel('Probability')
ax2.set_title('(b) Steady-State Distribution')
ax2.legend()
ax2.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()

# Validate the mean
simulated_mean = np.mean(final_counts)
print(f"Theoretical mean: {lambda_theory:.1f}")
print(f"Simulated mean: {simulated_mean:.1f}")
print(f"Relative error: {abs(simulated_mean - lambda_theory)/lambda_theory*100:.1f}%")
Figure 2.8: Gillespie simulation of the constitutive gene model. Panel (a) shows sample trajectories demonstrating the stochastic jumps in molecule number over time. Panel (b) compares the steady-state distribution from 10,000 simulation runs (histogram) with the theoretical Poisson distribution (red line), confirming the algorithm’s exactness.
Theoretical mean: 20.0
Simulated mean: 19.8
Relative error: 0.8%

The perfect agreement between simulation and theory validates our algorithm and our understanding. We’ve successfully built a computational microscope that lets us watch individual molecules being born and destroyed in real time.

2.5 Some Models

Now that we are equipped with two lenses: the chemical master equation for P(n,t) and the Gillespie algorithm for sampling trajectories from these processes, we can now discuss a few classical, notable models of gene expression.

2.5.1 The Telegraph Model: Genes Switching On and Off

The mathematical description of this process is called the Telegraph Model or two-state model. It involves four reactions:

\begin{align} \text{Gene OFF} &\xrightarrow{k_{\text{on}}} \text{Gene ON} \\ \text{Gene ON} &\xrightarrow{k_{\text{off}}} \text{Gene OFF} \\ \text{Gene ON} &\xrightarrow{\beta} \text{Gene ON + mRNA} \\ \text{mRNA} &\xrightarrow{\gamma} \emptyset \end{align}

Here:

  • k_{\text{on}}: rate of gene activation
  • k_{\text{off}}: rate of gene inactivation
  • \beta: transcription rate when gene is active
  • \gamma: mRNA degradation rate

This model captures the reality of chromatin dynamics and transcriptional regulation. The “off” state represents closed chromatin where transcription factors cannot access the promoter. The “on” state represents open chromatin with active transcriptional machinery. The random switching between states reflects the stochastic binding and unbinding of regulatory proteins.

Let’s implement this model and see what transcriptional bursting looks like in practice.

Code
import numpy as np
import matplotlib.pyplot as plt

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def gillespie_telegraph(k_on, k_off, beta, gamma, t_max, gene_initial=0, mrna_initial=0):
    """
    Simulate the Telegraph model using Gillespie algorithm
    
    Parameters:
    k_on: rate of gene activation
    k_off: rate of gene inactivation  
    beta: transcription rate when gene is active
    gamma: mRNA degradation rate
    t_max: simulation time
    """
    # Initial state
    gene_state = gene_initial  # 0=OFF, 1=ON
    mrna_count = mrna_initial
    t = 0
    
    # Store trajectory
    history_t = [0]
    history_gene = [gene_state]
    history_mrna = [mrna_count]
    
    while t < t_max:
        # Calculate propensities based on current state
        if gene_state == 0:  # Gene OFF
            a_on = k_on
            a_off = 0
            a_transcribe = 0
        else:  # Gene ON
            a_on = 0
            a_off = k_off
            a_transcribe = beta
            
        a_degrade = gamma * mrna_count
        a_total = a_on + a_off + a_transcribe + a_degrade
        
        if a_total == 0:
            break
            
        # Time to next reaction
        tau = -np.log(np.random.random()) / a_total
        
        # Which reaction occurs?
        r = np.random.random() * a_total
        
        if r < a_on:
            gene_state = 1  # Turn ON
        elif r < a_on + a_off:
            gene_state = 0  # Turn OFF
        elif r < a_on + a_off + a_transcribe:
            mrna_count += 1  # Transcribe
        else:
            mrna_count = max(0, mrna_count - 1)  # Degrade
            
        t += tau
        history_t.append(t)
        history_gene.append(gene_state)
        history_mrna.append(mrna_count)
    
    return np.array(history_t), np.array(history_gene), np.array(history_mrna)

# Parameters for moderate bursting
k_on = 0.05   # Rate of switching to ON state
k_off = 0.2   # Rate of switching to OFF state
beta = 20.0   # Transcription rate when ON
gamma = 1.0   # mRNA degradation rate
t_max = 200

np.random.seed(42)
times, gene_states, mrna_counts = gillespie_telegraph(k_on, k_off, beta, gamma, t_max)

# Create time grid for step plotting
time_grid = np.linspace(0, t_max, 1000)
gene_interp = np.interp(time_grid, times, gene_states)
mrna_interp = np.interp(time_grid, times, mrna_counts)

# Plotting
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)

# Plot Gene State
ax1.step(times, gene_states, where='post', color=QUALITATIVE_COLORS[0], linewidth=1.5)
ax1.fill_between(times, gene_states, alpha=0.3, color=QUALITATIVE_COLORS[0], step='post')
ax1.set_yticks([0, 1])
ax1.set_yticklabels(['OFF', 'ON'])
ax1.set_ylabel('Gene State')
ax1.set_ylim(-0.1, 1.1)
ax1.grid(True, alpha=0.3)
ax1.set_title('Telegraph Model: Transcriptional Bursting')

# Plot mRNA count
ax2.step(times, mrna_counts, where='post', color=QUALITATIVE_COLORS[1], linewidth=1.5)
ax2.set_xlabel('Time')
ax2.set_ylabel('mRNA Count')
ax2.grid(True, alpha=0.3)
ax2.set_ylim(bottom=0)

plt.tight_layout()
plt.show()
Figure 2.9: A simulation of the Telegraph model. The top panel shows the stochastic switching of the gene’s promoter between an ON (1) and OFF (0) state. The bottom panel shows the corresponding mRNA copy number over time. Transcription only occurs during the ON state, leading to rapid increases or ‘bursts’ of mRNA, followed by exponential decay. This bursting behavior is the source of the high variance seen in experimental data.

The simulation reveals the dramatic difference between the Telegraph model and simple constitutive expression. Instead of small fluctuations around a steady mean, we see large, intermittent spikes in mRNA levels. This is transcriptional bursting in action.

2.5.2 The Geometry of Bursts and the Negative Binomial

The Telegraph model gives us a complete, microscopic description of gene switching. However, in many biological scenarios, we can simplify it even further to build a more intuitive, phenomenological model. This simplification is valid under a specific and common limit: when the gene promoter switches off much faster than it switches on (k_{on} \ll k_{off}), and when mRNA degradation is slow compared to the off-switching rate (\gamma \ll k_{off}).

In this “bursty” limit, the gene spends most of its time in the OFF state. Occasionally, it flips ON for a very brief period, producing a quick “burst” of transcripts before rapidly flipping OFF again. Our goal is to formalize this picture by deriving the properties of this simplified bursty model directly from the Telegraph model.

First, let’s characterize the bursts themselves. A burst is the set of transcripts produced during a single ON-period. The duration of this period is a random variable drawn from an exponential distribution with rate k_{off}. During this time, transcripts are produced via a Poisson process with rate \beta. What is the distribution of the number of transcripts, n, produced in a single burst?

Deriving the Geometric Burst Size Distribution

Let T_{on} be the time the gene stays in the ON state, with P(T_{on}=t) = k_{off}e^{-k_{off}t}. Given a fixed duration t, the number of transcripts n produced is Poisson-distributed with rate \beta t: P(n | T_{on}=t) = \frac{(\beta t)^n}{n!}e^{-\beta t}

To find the total probability of producing n transcripts in a burst, we must average over all possible durations t: P(n) = \int_0^\infty P(n | T_{on}=t) P(T_{on}=t) dt P(n) = \int_0^\infty \left( \frac{(\beta t)^n}{n!}e^{-\beta t} \right) (k_{off}e^{-k_{off}t}) dt

Rearranging the terms: P(n) = \frac{k_{off}\beta^n}{n!} \int_0^\infty t^n e^{-(\beta+k_{off})t} dt

The integral is a standard form related to the Gamma function, which evaluates to \frac{n!}{(\beta+k_{off})^{n+1}}. Substituting this back in, we get:

P(n) = \frac{k_{off}\beta^n}{n!} \frac{n!}{(\beta+k_{off})^{n+1}} = \frac{k_{off}}{\beta+k_{off}} \left( \frac{\beta}{\beta+k_{off}} \right)^n

This is a geometric distribution for n=0, 1, 2, \ldots. If we define the probability of “success” (producing one more transcript before inactivation) as p = \frac{\beta}{\beta+k_{off}}, then the probability of “failure” (inactivation) is 1-p = \frac{k_{off}}{\beta+k_{off}}. The distribution is P(n) = (1-p)p^n.

The mean of this distribution is the average burst size, \langle b \rangle: \langle b \rangle = \frac{p}{1-p} = \frac{\beta/(\beta+k_{off})}{k_{off}/(\beta+k_{off})} = \frac{\beta}{k_{off}} This result shows that the average number of transcripts per burst is simply the ratio of the transcription rate to the inactivation rate.

The derivation of a geometric burst size is a powerful result. It allows us to formulate a simplified phenomenological model that captures the essential features of transcriptional bursting without explicitly tracking the gene’s state. This is valid in the common limit where the gene switches off much faster than it switches on (k_{on} \ll k_{off}).

Instead of the four reactions of the full Telegraph model, we can now describe the system with a more abstract, but more intuitive, two-step process:

  1. Bursty Production: Bursts of mRNA are produced in a single, composite event.
  2. Degradation: Individual mRNA molecules are degraded one by one.

We can write this as a formal reaction scheme: \begin{align*} \emptyset &\xrightarrow{k_{on}} j \cdot \text{mRNA} \quad \text{with } j \sim \text{Geometric}(\langle b \rangle = \beta/k_{off}) \\ \text{mRNA} &\xrightarrow{\gamma} \emptyset \end{align*} Here, bursts arrive as a Poisson process with rate k_{on}. Each event adds a random number of mRNA molecules, j, drawn from the geometric distribution we just derived.

From this scheme, we can write the Chemical Master Equation for the probability P(m) of having m mRNA molecules at steady state. The change in probability for state m is the balance of flux in and flux out: 0 = \underbrace{\gamma(m+1)P(m+1) - \gamma m P(m)}_{\text{Flux from Degradation}} + \underbrace{k_{on} \left( \sum_{j=0}^{m} P_{\text{burst}}(j)P(m-j) - P(m) \right)}_{\text{Flux from Bursty Production}} where P_{\text{burst}}(j) is the probability of a burst of size j. The summation term is a convolution, representing all the ways a burst of size j can lead to state m from a previous state m-j.

While this CME is simpler than the coupled equations for the full Telegraph model, solving it directly is still challenging. However, it can be shown that the steady-state solution to this equation is the Negative Binomial distribution. We will derive this result formally in a later section using moment generating functions, but for now, let’s explore its parameters and their connection to the underlying biology.

The Negative Binomial distribution gives the probability of observing m “failures” before the r-th “success” in a series of Bernoulli trials with success probability p. Its probability mass function is:

P(m | r, p) = \binom{m+r-1}{m} p^r (1-p)^m

The power of this result is that the abstract statistical parameters r and p can be directly mapped to the physical parameters of our bursting model:

  • Mean Burst Size (b): The average number of transcripts produced during a single ON-state event. The average duration of an ON event is 1/k_{off}. During this time, transcripts are made at rate \beta. So, the mean burst size is b = \beta / k_{off}.
  • Burst Frequency: The rate at which bursts are initiated, which is simply the gene activation rate, k_{on}.

These physical quantities connect to the Negative Binomial parameters as follows:

  • r = \frac{k_{on}}{\gamma}: This is the dimensionless burst frequency, representing how many bursts occur on average within the lifetime of a single mRNA molecule (1/\gamma).
  • p = \frac{1}{1+b} = \frac{1}{1 + \beta/k_{off}} = \frac{k_{off}}{k_{off}+\beta}: This probability is determined by the mean burst size b. A larger burst size b leads to a smaller p.

With these relationships established, we can now calculate the mean and variance of the mRNA distribution from the known properties of the Negative Binomial distribution:

\langle m \rangle = \frac{r(1-p)}{p} = r \cdot b = \left(\frac{k_{\text{on}}}{\gamma}\right) \left(\frac{\beta}{k_{\text{off}}}\right)

\sigma^2_m = \frac{r(1-p)}{p^2} = \frac{\langle m \rangle}{p} = \langle m \rangle (1+b)

This result is powerful. It tells us that the average number of mRNAs, \langle m \rangle, is the product of the number of bursts per mRNA lifetime (r) and the average number of molecules per burst (b). Furthermore, the variance is directly related to the mean and the burst size. The Fano factor, a measure of noise, is therefore:

F = \frac{\sigma^2_m}{\langle m \rangle} = 1+b = 1 + \frac{\beta}{k_{\text{off}}}

This gives us a direct experimental handle: if we can measure the mean and variance of mRNA counts in a cell population, we can infer the underlying burst size and frequency. This rigorously connects the microscopic parameters of gene switching to the macroscopic, experimentally observable statistics of mRNA distributions.

Code
import numpy as np
import matplotlib.pyplot as plt

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

# This function is from the previous block, included here for completeness
def gillespie_telegraph_with_burst_tracking(k_on, k_off, beta, gamma, t_max, gene_initial=0, mrna_initial=0):
    """
    Simulate the Telegraph model using Gillespie algorithm with direct burst size tracking
    """
    # Initial state
    gene_state = gene_initial  # 0=OFF, 1=ON
    mrna_count = mrna_initial
    t = 0
    
    # Store trajectory
    history_t = [0]
    history_gene = [gene_state]
    history_mrna = [mrna_count]
    
    # Track bursts directly
    burst_sizes = []
    current_burst_size = 0
    
    while t < t_max:
        # Calculate propensities based on current state
        if gene_state == 0:  # Gene OFF
            a_on = k_on
            a_off = 0
            a_transcribe = 0
        else:  # Gene ON
            a_on = 0
            a_off = k_off
            a_transcribe = beta
            
        a_degrade = gamma * mrna_count
        a_total = a_on + a_off + a_transcribe + a_degrade
        
        if a_total == 0:
            break
            
        # Time to next reaction
        tau = -np.log(np.random.random()) / a_total
        
        # Which reaction occurs?
        r = np.random.random() * a_total
        
        if r < a_on:
            gene_state = 1  # Turn ON
            current_burst_size = 0  # Reset burst counter
        elif r < a_on + a_off:
            gene_state = 0  # Turn OFF
            # Record completed burst (including zero-sized bursts)
            burst_sizes.append(current_burst_size)
            current_burst_size = 0
        elif r < a_on + a_off + a_transcribe:
            mrna_count += 1  # Transcribe
            current_burst_size += 1  # Count this transcription event
        else:
            mrna_count = max(0, mrna_count - 1)  # Degrade
            
        t += tau
        history_t.append(t)
        history_gene.append(gene_state)
        history_mrna.append(mrna_count)
    
    return np.array(history_t), np.array(history_gene), np.array(history_mrna), burst_sizes

# Parameters from the Telegraph model simulation (fig-telegraph-simulation)
k_on = 0.05   
k_off = 0.2   
beta = 20.0   
gamma = 1.0   

# --- Create Figure ---
fig, (ax1, ax2) = plt.subplots(1, 2)

# --- Panel A: Theoretical Exploration ---
b_values = [5, 10, 20]
colors = [QUALITATIVE_COLORS[0], QUALITATIVE_COLORS[1], QUALITATIVE_COLORS[3]]  # Red, blue, yellow
x_range = np.arange(0, 101)

for b, color in zip(b_values, colors):
    # For a geometric distribution P(n)=(1-p)p^n, the mean is b = p/(1-p).
    # So, p = b / (1 + b).
    p = b / (1 + b)
    pmf = (1 - p) * (p**x_range)
    
    ax1.plot(x_range, pmf, 'o-', color=color, linewidth=2, markersize=3,
             label=f'b = {b}')

ax1.set_xlabel('Burst Size (n)')
ax1.set_ylabel('Probability P(n)')
ax1.set_title('(a) Theoretical Geometric Distributions')
ax1.legend()
ax1.grid(True, alpha=0.3)
ax1.set_xlim(0, 60)

# --- Panel B: Theory vs. Simulation ---

# Run a long simulation to collect many bursts
np.random.seed(123)
t_max_long = 10000 # Longer simulation for better stats
_, _, _, observed_bursts = gillespie_telegraph_with_burst_tracking(
    k_on, k_off, beta, gamma, t_max_long)

# Theoretical geometric distribution for the simulation parameters
mean_burst_size_sim = beta / k_off
p_sim = mean_burst_size_sim / (1 + mean_burst_size_sim)

# Generate theoretical distribution
max_burst_obs = max(observed_bursts) if observed_bursts else 1
burst_range_sim = np.arange(0, max_burst_obs + 50) # Extend range for plotting
theoretical_probs_sim = (1 - p_sim) * (p_sim**burst_range_sim)

# Plot histogram of observed bursts
max_bin = int(np.percentile(observed_bursts, 99.9)) if observed_bursts else 1

ax2.hist(observed_bursts, 
         density=True, alpha=0.6, color=QUALITATIVE_COLORS[1], edgecolor='none',
         label='Simulation')

# Plot theoretical overlay
ax2.plot(burst_range_sim, theoretical_probs_sim, 'o-', color=QUALITATIVE_COLORS[0], linewidth=2, markersize=4,
         label=f'Geometric Theory (b={mean_burst_size_sim:.0f})')

ax2.set_xlabel('Burst Size (n)')
ax2.set_ylabel('Probability P(n)')
ax2.set_title('(b) Simulation vs. Theory')
ax2.legend()
ax2.grid(True, alpha=0.3)
ax2.set_xlim(left=-1, right=max_bin + 1)

plt.tight_layout()
plt.show()

# Validate the mean
if observed_bursts:
    observed_mean = np.mean(observed_bursts)
    print(f"Theoretical mean burst size: {mean_burst_size_sim:.2f}")
    print(f"Observed mean burst size: {observed_mean:.2f}")
    print(f"Relative error: {abs(observed_mean - mean_burst_size_sim)/mean_burst_size_sim*100:.1f}%")
Figure 2.10: The geometric distribution of transcriptional burst sizes. Panel (a) shows theoretical geometric distributions for different mean burst sizes (b). As b increases, the distribution becomes broader with a longer tail, meaning larger bursts become more probable, though the most likely burst is always zero. Panel (b) validates this theory against a long Gillespie simulation of the Telegraph model (parameters: β=20, k_off=0.2, giving a mean burst size b=100). The histogram of observed burst sizes from the simulation perfectly matches the theoretical geometric distribution (red line), confirming that the complex dynamics of gene switching follow this simple rule.
Theoretical mean burst size: 100.00
Observed mean burst size: 100.60
Relative error: 0.6%

The perfect agreement between simulation and theory confirms our understanding. This theoretical prediction of geometric burst sizes matches closely with the experimental observations from the Cai experiment shown earlier (Figure 2.7)—panel (c) of that figure directly validates our derived geometric distribution.

Now that we are equipped with the Gillespie algorithm, a powerful computational microscope, we are no longer limited to the simplest models. We can begin to explore more complex and realistic scenarios that capture deeper biological truths. Let’s investigate two such models that each teach a crucial lesson about how stochasticity operates in the cell.

2.5.3 The Two-Stage Model: Where Do Protein Bursts Come From?

We’ve seen that the Telegraph model provides a compelling microscopic explanation for the origin of mRNA bursts. But in many experiments, we measure proteins, not mRNA. How does the noise from the short-lived mRNA population get transmitted to the more stable protein population? To answer this, we need a two-stage model that explicitly includes both transcription and translation.

This model provides a beautiful lesson in timescale separation. In many organisms, from yeast to mammals, mRNA molecules are much less stable than the proteins they code for. From the perspective of a long-lived protein, the entire lifecycle of an individual mRNA transcript—from its birth to its death—is just a brief flash. But during that flash, it can serve as a template for many protein molecules. This model assumes a constant translation rate per mRNA, but in reality, translation itself can be a bursty process due to factors like ribosome pausing and variable initiation rates, adding another layer of complexity to protein noise. This is the microscopic origin of protein bursts.

2.5.3.1 The Model and its Simplification

Let’s formalize this. The full two-stage model for a constitutively expressed gene consists of four fundamental reactions:

  1. Transcription: An mRNA molecule (m) is produced at rate \beta_m. ∅ → m
  2. mRNA Degradation: An mRNA molecule is degraded at a per-molecule rate \gamma_m. m → ∅
  3. Translation: Each mRNA molecule produces protein (p) at a per-molecule rate \beta_p. m → m + p
  4. Protein Degradation: A protein molecule is degraded at a per-molecule rate \gamma_p. p → ∅

The key insight, as shown by Shahrezaei and Swain (2008), comes from considering the common biological case where mRNA degrades much faster than protein (\gamma_m \gg \gamma_p). During the short lifetime of a single mRNA molecule, a random number of proteins are produced. We can calculate the distribution of this number, which we’ll call the protein burst size, b.

Deriving the Geometric Protein Burst Size

The number of proteins produced from a single mRNA molecule follows a geometric distribution. This fact arises from a competition between two Poisson processes: translation, which occurs at rate \beta_p, and mRNA degradation, which occurs at rate \gamma_m.

For a single mRNA molecule, the total rate of any event is k_{\text{total}} = \beta_p + \gamma_m. The probability that the next event is a translation (a “success”) is the ratio of the translation rate to the total rate: p = \frac{\beta_p}{\beta_p + \gamma_m} Conversely, the probability that the next event is mRNA degradation (a “failure,” which terminates the burst) is: 1-p = \frac{\gamma_m}{\beta_p + \gamma_m} A protein burst of size b requires a sequence of b successful translations followed by one terminal degradation event. The probability of this specific sequence is P(\text{burst size} = b) = p^b \cdot (1-p), which is the probability mass function for a geometric distribution over b=0, 1, 2, \ldots.

The mean of this distribution, \langle b \rangle = p/(1-p), gives the mean protein burst size. Substituting the expressions for p and 1-p yields a foundational result: \langle b \rangle = \frac{\beta_p / (\beta_p + \gamma_m)}{\gamma_m / (\beta_p + \gamma_m)} = \frac{\beta_p}{\gamma_m} Thus, the average number of proteins produced per mRNA molecule is simply the ratio of the translation rate to the mRNA degradation rate. This same mathematical structure appears whenever a continuous process (like translation) competes with a discrete termination event (like mRNA degradation).

This derivation provides the theoretical foundation for simplifying the four-reaction system into an effective two-reaction model for protein levels:

  1. Bursty Production: Protein bursts are produced at a rate \beta_m (the transcription rate). The size of each burst, b, is a random integer drawn from a geometric distribution with a mean of \langle b \rangle = \beta_p / \gamma_m.
  2. Protein Degradation: Individual proteins are degraded at a rate \gamma_p.

This is precisely the phenomenological bursting model we introduced earlier, but now it is derived from the underlying molecular reactions. This effective model predicts that the steady-state protein distribution will follow a Negative Binomial distribution, where the parameters are determined by the burst frequency (r = \beta_m / \gamma_p) and the mean burst size (p = 1/(1+\langle b \rangle)).

Let’s test this powerful idea. We can run a Gillespie simulation of the full, four-reaction two-stage model and compare the resulting protein distribution to the analytical Negative Binomial distribution predicted by our simplified bursting model.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import nbinom

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def gillespie_two_stage(beta_m, gamma_m, beta_p, gamma_p, t_max, m_initial=0, p_initial=0):
    """Simulate the two-stage model of gene expression."""
    t = 0.0
    m, p = m_initial, p_initial
    history_t = [t]
    history_p = [p]
    
    while t < t_max:
        # Propensities
        a_m_prod = beta_m
        a_m_deg = gamma_m * m
        a_p_prod = beta_p * m
        a_p_deg = gamma_p * p
        a_total = a_m_prod + a_m_deg + a_p_prod + a_p_deg
        
        if a_total == 0:
            break
        
        tau = -np.log(np.random.rand()) / a_total
        r = np.random.rand() * a_total
        
        if r < a_m_prod:
            m += 1
        elif r < a_m_prod + a_m_deg:
            m = max(0, m - 1)
        elif r < a_m_prod + a_m_deg + a_p_prod:
            p += 1
        else:
            p = max(0, p - 1)
        
        t += tau
        history_t.append(t)
        history_p.append(p)
        
    return np.array(history_t), np.array(history_p)

# Parameters that satisfy timescale separation (gamma_m >> gamma_p)
beta_m = 0.5      # mRNA production rate
gamma_m = 10.0    # mRNA degradation rate (fast)
beta_p = 200.0    # Protein production rate per mRNA
gamma_p = 1.0     # Protein degradation rate (slow)

# Run simulations
n_sims = 5000
final_p_counts = []
for _ in range(n_sims):
    _, p_hist = gillespie_two_stage(beta_m, gamma_m, beta_p, gamma_p, 50)
    final_p_counts.append(p_hist[-1])

# Theoretical Negative Binomial parameters
mean_burst_size = beta_p / gamma_m
burst_freq = beta_m / gamma_p
p_nb = 1 / (1 + mean_burst_size)
r_nb = burst_freq

# Plotting
fig, ax = plt.subplots()
max_val = int(np.percentile(final_p_counts, 99.9))
bins = np.arange(-0.5, max_val + 1.5, 1)

ax.hist(final_p_counts, bins=bins, density=True, alpha=0.75, color=QUALITATIVE_COLORS[1], edgecolor='none', label='Full Simulation')

# Theoretical overlay
x_range = np.arange(0, max_val + 1)
pmf = nbinom.pmf(x_range, r_nb, p_nb)
ax.plot(x_range, pmf, 'o-', color=QUALITATIVE_COLORS[0], linewidth=2, markersize=4, label='Negative Binomial Approx.')

ax.set_xlabel('Protein Count (p)')
ax.set_ylabel('Probability')
ax.set_title('Two-Stage Model vs. Bursting Approximation')
ax.legend()
ax.grid(True, alpha=0.3)
ax.set_xlim(left=-1)
plt.show()

print(f"Mean burst size (b) = {mean_burst_size:.1f}")
print(f"Effective burst frequency (r) = {burst_freq:.2f}")
Figure 2.11: Validation of the timescale separation approximation. The histogram shows the steady-state protein distribution from a Gillespie simulation of the full four-reaction (transcription-translation) model. The red line is the theoretical Negative Binomial distribution predicted by the simplified bursting model, derived using the timescale separation argument. The excellent agreement confirms that when mRNA is unstable relative to protein, the complex two-stage process can be accurately approximated as a simple bursty production of proteins.
Mean burst size (b) = 20.0
Effective burst frequency (r) = 0.50

2.5.4 Stochastic Autoregulation: Feedback Sculpts the Noise

The models we’ve seen so far are all “open-loop”—the production rate of a gene doesn’t depend on the number of molecules already present. This is a good starting point, but the essence of genetic regulation lies in feedback. What happens when a protein product comes back to control the activity of its own gene? This brings the ideas of stability and bistability from Chapter 1 crashing into the stochastic world of this chapter.

The lesson here is that feedback directly sculpts the shape of the probability distribution. Nonlinear reaction rates, which arise from feedback, can dramatically alter the noise profile of a gene, either suppressing it to ensure stability or amplifying it to create distinct cellular phenotypes.

2.5.4.1 The Models and Their Consequences

A fully realistic model of feedback might involve adapting our Telegraph model, making the promoter switching rates (k_{\text{on}} and k_{\text{off}}) dependent on the protein count. While powerful, this adds complexity. To isolate the core effect of feedback, we can study a simpler model: a direct birth-death process where the protein production rate itself is a function of the protein count, n. Instead of a constant production rate \beta, we now have a state-dependent rate, \beta(n).

  • Negative Autoregulation: The protein acts as a repressor. As the protein count n increases, it hinders its own production, causing the production rate \beta(n) to decrease. We can model this using a repressive Hill function, just as we did in the deterministic models: \beta(n) = \frac{\beta_{max}}{1 + (n/K)^h} This self-correcting mechanism is a powerful noise-reduction strategy. If a random fluctuation causes n to become too high, the production rate drops, pulling the level back down. Conversely, if n is too low, production increases. The result is a probability distribution that is significantly narrower than that of an unregulated gene with the same average expression.

  • Positive Autoregulation: The protein acts as an activator. As n increases, it promotes its own expression, causing the production rate \beta(n) to increase, which we can model with an activating Hill function: \beta(n) = \beta_0 + \frac{\beta_{max} n^h}{K^h + n^h} This self-reinforcing loop is a noise-amplifying mechanism. Small, random increases in n are locked in and amplified, pushing the system toward a high-expression state. This can lead to bimodality, where the cell population splits into two distinct groups: one with low expression and one with high expression. This is the stochastic signature of the bistable switch from Chapter 1!

Let’s use the Gillespie algorithm to see these two principles in action.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def simple_birth_death_simulator(birth_rate_func, death_rate, t_max, n_initial=0):
    """
    Simplified birth-death process where birth rate can depend on current count.
    This avoids the complexity of the telegraph model.
    """
    t = 0
    n = n_initial
    
    while t < t_max:
        birth_rate = birth_rate_func(n)
        death = death_rate * n
        
        total_rate = birth_rate + death
        if total_rate == 0:
            break
            
        tau = -np.log(np.random.rand()) / total_rate
        t += tau
        
        if t >= t_max:
            break
            
        if np.random.rand() < birth_rate / total_rate:
            n += 1
        else:
            n = max(0, n - 1)
    
    return n

# Set up figure
np.random.seed(123)
fig, (ax1, ax2) = plt.subplots(1, 2)

# ============= PANEL A: NEGATIVE FEEDBACK =============
n_sims = 1000  # Many simulations for smooth distributions
t_equilibrate = 200  # Time to reach steady state

# Unregulated system: constant birth rate
target_mean = 50
death_rate = 1.0
birth_rate_unreg = target_mean * death_rate  # To get mean = birth/death = 50

unreg_birth = lambda n: birth_rate_unreg
unreg_samples = [simple_birth_death_simulator(unreg_birth, death_rate, t_equilibrate, 
                                              n_initial=int(target_mean)) 
                 for _ in range(n_sims)]

# Negative feedback: birth rate decreases with n
# Use Hill function: birth = b_max / (1 + (n/K)^h)
b_max = 150  # Maximum birth rate
K_neg = 35   # Half-saturation constant  
h_neg = 2    # Hill coefficient

neg_fb_birth = lambda n: b_max / (1 + (n/K_neg)**h_neg)
neg_fb_samples = [simple_birth_death_simulator(neg_fb_birth, death_rate, t_equilibrate,
                                               n_initial=int(target_mean))
                  for _ in range(n_sims)]

# Plot distributions for negative feedback
bins = np.arange(0, 120, 2)
hist_unreg, edges = np.histogram(unreg_samples, bins=bins, density=True)
hist_neg, _ = np.histogram(neg_fb_samples, bins=bins, density=True)
centers = (edges[:-1] + edges[1:]) / 2

ax1.plot(centers, hist_unreg, '-', color=QUALITATIVE_COLORS[0], linewidth=2.5, label=f'Unregulated (CV²={np.var(unreg_samples)/np.mean(unreg_samples)**2:.3f})', alpha=0.8)
ax1.fill_between(centers, hist_unreg, alpha=0.3, color=QUALITATIVE_COLORS[0])

ax1.plot(centers, hist_neg, '-', color=QUALITATIVE_COLORS[1], linewidth=2.5, label=f'Negative FB (CV²={np.var(neg_fb_samples)/np.mean(neg_fb_samples)**2:.3f})', alpha=0.8)
ax1.fill_between(centers, hist_neg, alpha=0.3, color=QUALITATIVE_COLORS[1])

# Mark means
ax1.axvline(np.mean(unreg_samples), color=QUALITATIVE_COLORS[0], linestyle='--', linewidth=2, alpha=0.6)
ax1.axvline(np.mean(neg_fb_samples), color=QUALITATIVE_COLORS[1], linestyle='--', linewidth=2, alpha=0.6)

ax1.set_xlabel('Protein Count', fontsize=12)
ax1.set_ylabel('Probability Density', fontsize=12)
ax1.set_title('(a) Negative Feedback Reduces Noise', fontsize=13, weight='bold')
ax1.legend(loc='upper right')
ax1.grid(True, alpha=0.3)
ax1.set_xlim(0, 110)

# ============= PANEL B: POSITIVE FEEDBACK =============
# Positive feedback: birth rate increases with n
# Use sigmoid: birth = b_basal + b_max * n^h / (K^h + n^h)
b_basal = 0.5   # Very low basal rate
b_max_pos = 80  # Maximum additional birth rate
K_pos = 30      # Threshold for activation
h_pos = 4       # Strong cooperativity

pos_fb_birth = lambda n: b_basal + b_max_pos * (n**h_pos) / (K_pos**h_pos + n**h_pos)

# Run simulations from two different initial conditions
n_sims_pos = 1000
# Start half from LOW state
pos_fb_low = [simple_birth_death_simulator(pos_fb_birth, death_rate, t_equilibrate,
                                           n_initial=0)
              for _ in range(n_sims_pos // 2)]

# Start half from HIGH state  
pos_fb_high = [simple_birth_death_simulator(pos_fb_birth, death_rate, t_equilibrate,
                                            n_initial=70)
               for _ in range(n_sims_pos // 2)]

all_pos_fb = pos_fb_low + pos_fb_high

# For comparison, show the unregulated distribution in gray
bins_pos = np.arange(0, 100, 2)
hist_unreg_b, edges_b = np.histogram(unreg_samples, bins=bins_pos, density=True)
hist_pos, _ = np.histogram(all_pos_fb, bins=bins_pos, density=True)
centers_b = (edges_b[:-1] + edges_b[1:]) / 2

# Plot unregulated as reference
ax2.plot(centers_b, hist_unreg_b, 'gray', linewidth=2, label='Unregulated', alpha=0.5)
ax2.fill_between(centers_b, hist_unreg_b, alpha=0.2, color='gray')

# Plot positive feedback distribution
ax2.plot(centers_b, hist_pos, color=QUALITATIVE_COLORS[5], linewidth=2.5, label='Positive FB')
ax2.fill_between(centers_b, hist_pos, alpha=0.4, color=QUALITATIVE_COLORS[5])

# Mark the two states
low_state = [x for x in all_pos_fb if x < 15]
high_state = [x for x in all_pos_fb if x > 15]

if len(low_state) > 0:
    ax2.axvline(np.mean(low_state), color=QUALITATIVE_COLORS[5], linestyle=':', linewidth=2,
                alpha=0.7, label=f'OFF state (mean={np.mean(low_state):.1f})')
if len(high_state) > 0:
    ax2.axvline(np.mean(high_state), color=QUALITATIVE_COLORS[5], linestyle='--', linewidth=2,
                alpha=0.7, label=f'ON state (mean={np.mean(high_state):.1f})')

ax2.set_xlabel('Protein Count', fontsize=12)
ax2.set_ylabel('Probability Density', fontsize=12)
ax2.set_title('(b) Positive Feedback Creates Bistability', fontsize=13, weight='bold')
ax2.legend(loc='upper left', fontsize=10)
ax2.grid(True, alpha=0.3)
ax2.set_xlim(-2, 95)

plt.tight_layout()
plt.show()

# Quantitative summary
print("=== QUANTITATIVE ANALYSIS ===")
print(f"\nNegative Feedback Comparison:")
print(f"  Unregulated: Mean={np.mean(unreg_samples):.1f}, CV²={np.var(unreg_samples)/np.mean(unreg_samples)**2:.3f}")
print(f"  Negative FB: Mean={np.mean(neg_fb_samples):.1f}, CV²={np.var(neg_fb_samples)/np.mean(neg_fb_samples)**2:.3f}")
print(f"  → Noise reduction: {(1 - np.var(neg_fb_samples)/np.mean(neg_fb_samples)**2 / (np.var(unreg_samples)/np.mean(unreg_samples)**2))*100:.0f}%")

print(f"\nPositive Feedback Analysis:")
frac_low = len(low_state) / len(all_pos_fb) * 100
frac_high = len(high_state) / len(all_pos_fb) * 100
print(f"  {frac_low:.0f}% in OFF state (mean={np.mean(low_state) if low_state else 0:.1f})")
print(f"  {frac_high:.0f}% in ON state (mean={np.mean(high_state) if high_state else 0:.1f})")
print(f"  Unregulated mean for reference: {np.mean(unreg_samples):.1f}")
Figure 2.12: Feedback sculpts the probability distribution. (a) Negative autoregulation reduces noise while maintaining the same mean expression level. The regulated system (blue) shows a narrower, more peaked distribution compared to the unregulated case (red). (b) Positive autoregulation creates bistability. The system exhibits two distinct stable states - cells are either ‘OFF’ or ‘ON’ with few intermediates, demonstrating how positive feedback enables switch-like behavior.
=== QUANTITATIVE ANALYSIS ===

Negative Feedback Comparison:
  Unregulated: Mean=50.0, CV²=0.019
  Negative FB: Mean=50.1, CV²=0.008
  → Noise reduction: 58%

Positive Feedback Analysis:
  50% in OFF state (mean=0.5)
  50% in ON state (mean=78.2)
  Unregulated mean for reference: 50.0

These models reveal a profound design principle: biology uses the same tool—feedback—for two opposite goals. Negative feedback is used to create robust, stable systems that buffer against fluctuations, essential for maintaining homeostasis. Positive feedback is used to create decisive, switch-like behaviors that drive cell-fate decisions and allow populations to diversify into distinct phenotypes. The ability to explore these opposing design strategies is one of the key powers that stochastic modeling gives us.

2.5.5 Biological vs. Technical Noise

So far, we have focused on biological noise—the inherent stochasticity of molecular processes within living cells. The Telegraph model provides a powerful framework for understanding this phenomenon. However, when we perform experiments, we encounter a real-world complication: technical noise from the measurement process is an additional source of dispersion that can further alter the distribution of observed counts in ways that we can quantify.

Consider single-cell RNA sequencing (scRNA-seq), the revolutionary technique that allows us to measure mRNA counts in individual cells. The experimental process involves cell lysis, mRNA capture, reverse transcription, and sequencing. At each step, molecules can be lost. The capture efficiency—the fraction of original mRNA molecules that are successfully detected—is often only 5-20%.

We can model this measurement process as binomial sampling. If a cell truly contains M molecules of a specific gene, and our technique has capture efficiency p_{capture}, then the number of molecules we actually observe, m_{obs}, follows a binomial distribution:

P(m_{obs} | M) = \binom{M}{m_{obs}} p_{capture}^{m_{obs}} (1 - p_{capture})^{M - m_{obs}}

This has profound consequences for data analysis. The noise we measure is a combination of two distinct components: the true biological variance from the underlying stochastic process, and the additional technical variance introduced by the binomial sampling process.

To untangle these, we can use two powerful rules from probability theory: the Law of Total Expectation and the Law of Total Variance. These laws allow us to calculate the mean and variance of the observed counts by first conditioning on the true (but unknown) number of molecules.

The observed mean and variance are related to the true values by:

  • Observed mean: \langle m_{obs} \rangle = p_{capture} \langle M_{true} \rangle
  • Observed variance: \text{Var}(m_{obs}) = p_{capture}^2 \text{Var}(M_{true}) + p_{capture}(1-p_{capture})\langle M_{true} \rangle

The second term in the variance equation, p_{capture}(1-p_{capture})\langle M_{true} \rangle, represents the added noise from the measurement process itself. This is the variance of a binomial distribution, averaged over the biological distribution of true molecule counts.

Deriving the Observed Mean and Variance

Let’s formalize the relationship between true and observed counts.

1. Define Variables and Distributions

  • M_{true}: The true number of molecules in a cell (a random variable).
  • m_{obs}: The observed number of molecules (a random variable).
  • p_{capture}: The capture efficiency (a constant).

The relationship between them is that the conditional distribution of the observed count given the true count is Binomial: m_{obs} | M_{true} \sim \text{Binomial}(M_{true}, p_{capture}) From this, we know the conditional moments:

  • E[m_{obs} | M_{true}] = M_{true} \cdot p_{capture}
  • \text{Var}(m_{obs} | M_{true}) = M_{true} \cdot p_{capture}(1 - p_{capture})

2. Deriving the Mean

We use the Law of Total Expectation: E[X] = E[E[X|Y]]. E[m_{obs}] = E[E[m_{obs} | M_{true}]] = E[M_{true} \cdot p_{capture}] = p_{capture} E[M_{true}] The observed mean is the true mean, scaled by the capture efficiency.

3. Deriving the Variance

We use the Law of Total Variance: \text{Var}(X) = E[\text{Var}(X|Y)] + \text{Var}(E[X|Y]).

Let’s calculate each term separately:

  • Term 1: Average Conditional Variance E[\text{Var}(m_{obs} | M_{true})] = E[M_{true} \cdot p_{capture}(1 - p_{capture})] = p_{capture}(1 - p_{capture})E[M_{true}]

  • Term 2: Variance of Conditional Mean \text{Var}(E[m_{obs} | M_{true}]) = \text{Var}(M_{true} \cdot p_{capture}) = p_{capture}^2 \text{Var}(M_{true})

Combining them gives the final result: \text{Var}(m_{obs}) = \underbrace{p_{capture}^2 \text{Var}(M_{true})}_{\text{Scaled Biological Variance}} + \underbrace{p_{capture}(1 - p_{capture})E[M_{true}]}_{\text{Technical Noise from Sampling}} This decomposition is powerful. It shows that the variance we measure is a sum of the scaled-down biological variance and an additional technical noise term that depends on the mean expression level.

Code
# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def gillespie_telegraph_snapshot(k_on, k_off, beta, gamma, t_max, n_initial=0):
    """
    Simulates the Telegraph model for a fixed time and returns the final mRNA count.
    """
    t = 0
    gene_state, n = 0, n_initial # gene_state: 0=OFF, 1=ON
    while t < t_max:
        propensities = np.array([
            (1 - gene_state) * k_on,  # Gene OFF -> ON
            gene_state * k_off,       # Gene ON -> OFF
            gene_state * beta,        # Transcription
            gamma * n                 # mRNA Degradation
        ])
        a_total = np.sum(propensities)
        if a_total == 0: break
        
        tau = -np.log(np.random.rand()) / a_total
        t += tau
        if t >= t_max: break
        
        r = np.random.rand() * a_total
        if r < propensities[0]:
            gene_state = 1
        elif r < propensities[0] + propensities[1]:
            gene_state = 0
        elif r < propensities[0] + propensities[1] + propensities[2]:
            n += 1
        else:
            n = max(0, n - 1)
    return n

# --- Define parameters for a clear pedagogical example ---
# These parameters generate a distribution with a higher mean (~125)
# and a clear shape, making the effect of sampling more visible.
k_on = 2.5
k_off = 0.5
beta = 50.0
gamma = 1.0
# ---------------------------------------------------------

# Generate "true" biological data using the shared helper function
n_cells = 300
true_counts = np.array([
    gillespie_telegraph_snapshot(k_on, k_off, beta, gamma, 100) for _ in range(n_cells)
])

# Simulate technical noise (binomial sampling)
capture_efficiency = 0.2
observed_counts = np.random.binomial(n=true_counts, p=capture_efficiency)

# Calculate statistics
true_mean = np.mean(true_counts)
observed_mean = np.mean(observed_counts)

# --- Plotting ---
# Use fewer, wider bins for cleaner visualization
bin_width = 5
max_count = int(np.percentile(true_counts, 99))
bins = np.arange(0, max_count + bin_width, bin_width)
fig, ax = plt.subplots()

# Use filled histograms with palette colors
ax.hist(true_counts, bins=bins, density=True, alpha=0.6, edgecolor='none',
        color=QUALITATIVE_COLORS[0], label=f'True (μ={true_mean:.1f})')
ax.hist(observed_counts, bins=bins, density=True, alpha=0.6, edgecolor='none',
        color=QUALITATIVE_COLORS[1], label=f'Observed (μ={observed_mean:.1f})')

# Add vertical lines for means (unlabeled for cleaner legend)
ax.axvline(true_mean, color=QUALITATIVE_COLORS[0], linestyle='--', linewidth=2, alpha=0.8)
ax.axvline(observed_mean, color=QUALITATIVE_COLORS[1], linestyle='--', linewidth=2, alpha=0.8)

ax.set_xlabel('mRNA Count')
ax.set_ylabel('Probability')
ax.set_title('Impact of Technical Noise on Gene Expression Data')
ax.legend()
ax.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()
Figure 2.13: The effect of technical noise on biological distributions. The blue histogram shows the ‘true’ biological distribution of mRNA counts from a Telegraph model simulation. The orange histogram shows the ‘observed’ distribution after binomial sampling with 20% capture efficiency. Technical noise reduces the mean, distorts the shape, and can obscure the underlying biological signal.

This example illustrates a fundamental challenge in quantitative biology: to understand the true biological processes, we must account for the technical limitations of our measurement tools. Simply fitting models to raw experimental data will lead to incorrect conclusions about the underlying biology. This distinction between biological and technical noise is crucial for interpreting scRNA-seq data. Many studies have found that accounting for technical noise dramatically changes estimates of biological parameters like burst frequency and burst size. This underscores why proper statistical inference—the subject of our next chapter—is essential for extracting biological insights from noisy experimental data.

The Gillespie algorithm is mathematically exact, but what happens when it becomes computationally intractable? For systems with large molecule numbers or very fast reactions, the algorithm requires simulating enormous numbers of individual events, making it too slow to be practical. This computational bottleneck poses the question: what approximation methods can we use when exact simulation is too expensive? To address that challenge, we need the advanced analytical frameworks explored in our next section.


2.6 Advanced Frameworks for Stochastic Analysis

While the Gillespie algorithm provides exact stochastic trajectories, it can be computationally slow. Furthermore, we often want analytical insight without running thousands of simulations. To address this, we will explore two powerful approximations: a continuous approach using Stochastic Differential Equations (SDEs) and a direct numerical approach called Finite State Projection (FSP). Finally, we will introduce analytical techniques using moment-generating functions.

2.6.1 The Mesoscopic View (Stochastic Differential Equations)

The Gillespie algorithm simulates every single reaction, which is exact but slow. Can we find a middle ground between this microscopic detail and the macroscopic world of ODEs? This is the “mesoscopic” view, which leads us to Stochastic Differential Equations (SDEs). The key idea is to approximate the discrete jumps of the CME with a continuous process that includes a random noise term.

Let’s build this from the ground up using our trusty constitutive gene model. The CME is: \frac{dP(n, t)}{dt} = \beta P(n-1, t) + \gamma(n+1)P(n+1, t) - (\beta + \gamma n)P(n, t) This equation describes the evolution of the probability P(n,t). We can use so-called “step operators” \mathbb{E} to write this more compactly. Let \mathbb{E} be an operator that steps up the molecule count, so \mathbb{E}f(n) = f(n+1), and \mathbb{E}^{-1} steps down, so \mathbb{E}^{-1}f(n) = f(n-1). The CME becomes: \frac{\partial P(n,t)}{\partial t} = \beta (\mathbb{E}^{-1}-1)P(n,t) + \gamma (\mathbb{E}-1) n P(n,t) Now, we apply the system size expansion ansatz. Any stochastic reaction network is built from independent reaction events. The key insight is that when we scale up the system size \Omega (e.g., cell volume), the machinery of reaction also scales. For instance, more transcription sites give a production propensity \beta \propto \Omega, and more molecules give a degradation propensity \gamma n \propto \Omega, since the molecule count n is itself extensive (n \propto \Omega). More generally, all reaction propensities a_j(\mathbf{n}) scale proportionally to \Omega because they represent the total rate of events in the enlarged system.

The scaling of the noise comes directly from the properties of this jump process. Let \Delta n be the change in molecule number over a small time interval dt. In the Gillespie framework, this equals \sum_j \nu_j N_j(dt), where N_j(dt) is the number of times reaction j occurs in time dt and \nu_j is the stoichiometric coefficient. Since each N_j(dt) follows a Poisson distribution with mean a_j(\mathbf{n}) dt, the variance becomes \text{Var}(\Delta n) = \sum_j \nu_j^2 a_j(\mathbf{n}) dt. Because each propensity a_j(\mathbf{n}) is proportional to \Omega, the variance also scales with \Omega. This means the magnitude of the fluctuations (the standard deviation) scales as \sqrt{\Omega}. We therefore decompose the molecule count into a deterministic part scaling with \Omega and stochastic fluctuations scaling as \sqrt{\Omega}: n(t) = \Omega x(t) + \sqrt{\Omega} \eta(t) where \Omega is the system size (representing the volume or total molecular scale), x(t) is the deterministic concentration, and \eta(t) represents the stochastic fluctuations that scale as \sqrt{\Omega}.

Substituting this ansatz into the CME requires expanding the step operators around the current state. Since n = \Omega x + \sqrt{\Omega} \eta, the step operators become: \mathbb{E}^{\pm 1}P(n,t) = P(\Omega x + \sqrt{\Omega} \eta \pm 1, t)

We can expand these using the Kramers-Moyal expansion (essentially a Taylor series). The key insight is that the \pm 1 shift is small compared to \Omega when the system size is large:

Kramers-Moyal Expansion Details

The step operators can be expanded using Taylor series around the current state. For a function f(n), we have: \mathbb{E}^{\pm 1} f(n) = f(n \pm 1) = f(n) \pm f'(n) + \frac{1}{2}f''(n) + O(1/\Omega)

This gives us the operator expansions: \mathbb{E}^{\pm 1} \approx 1 \pm \frac{\partial}{\partial n} + \frac{1}{2}\frac{\partial^2}{\partial n^2} + \text{higher order terms}

For large \Omega, the \pm 1 jumps become small relative to the total number of molecules, justifying this continuous approximation.

Converting derivatives with respect to n to our new variables requires the chain rule. Since n = \Omega x + \sqrt{\Omega} \eta, we have:

Chain Rule Derivation

Starting from n = \Omega x + \sqrt{\Omega} \eta, we need to express \frac{\partial}{\partial n} in terms of \frac{\partial}{\partial x} and \frac{\partial}{\partial \eta}.

From the inverse relationships: - x = \frac{n - \sqrt{\Omega}\eta}{\Omega}, so \frac{\partial x}{\partial n} = \frac{1}{\Omega} - \eta = \frac{n - \Omega x}{\sqrt{\Omega}}, so \frac{\partial \eta}{\partial n} = \frac{1}{\sqrt{\Omega}}

Applying the chain rule: \frac{\partial}{\partial n} = \frac{\partial x}{\partial n}\frac{\partial}{\partial x} + \frac{\partial \eta}{\partial n}\frac{\partial}{\partial \eta} = \frac{1}{\Omega}\frac{\partial}{\partial x} + \frac{1}{\sqrt{\Omega}}\frac{\partial}{\partial \eta}

Substituting these expansions into the CME produces terms with different powers of \Omega. Let’s work through this systematically:

Algebraic Expansion by Powers of \Omega

Substituting the step operator expansions into the CME for the constitutive gene: \frac{\partial P}{\partial t} = \beta (\mathbb{E}^{-1}-1)P + \gamma (\mathbb{E}-1) n P

Production term: \beta(\mathbb{E}^{-1}-1)P = \beta\left(-\frac{\partial}{\partial n} + \frac{1}{2}\frac{\partial^2}{\partial n^2}\right)P = \beta\left(-\frac{1}{\Omega}\frac{\partial}{\partial x} - \frac{1}{\sqrt{\Omega}}\frac{\partial}{\partial \eta} + \frac{1}{2}\left(\frac{1}{\Omega}\frac{\partial}{\partial x} + \frac{1}{\sqrt{\Omega}}\frac{\partial}{\partial \eta}\right)^2\right)P

Degradation term: \gamma(\mathbb{E}-1)nP = \gamma\left(\frac{\partial}{\partial n} + \frac{1}{2}\frac{\partial^2}{\partial n^2}\right)(\Omega x + \sqrt{\Omega}\eta)P = \gamma\left(\frac{1}{\Omega}\frac{\partial}{\partial x} + \frac{1}{\sqrt{\Omega}}\frac{\partial}{\partial \eta}\right)(\Omega x + \sqrt{\Omega}\eta)P + \text{higher order}

Expanding and collecting terms by powers of \Omega: - O(\Omega^0) terms: deterministic dynamics - O(\Omega^{-1/2}) terms: stochastic fluctuations - O(\Omega^{-1}) terms and higher: corrections (neglected in leading order)

The zeroth order (deterministic) gives us the macroscopic rate equation:

Zeroth Order: Deterministic Dynamics

Collecting all O(\Omega^0) terms from our expansion, we get: \frac{\partial P}{\partial t} = \left[-\beta \frac{1}{\Omega}\frac{\partial}{\partial x} + \gamma \Omega x \frac{1}{\Omega}\frac{\partial}{\partial x}\right]P + O(\Omega^{-1/2})

For this to be well-defined, we need the coefficient of \frac{\partial}{\partial x} to be O(1). This requires \beta \propto \Omega. Setting \beta = \Omega \alpha where \alpha is an intensive rate, we get: \frac{\partial P}{\partial t} = \left[-\alpha + \gamma x\right]\frac{\partial P}{\partial x} + \text{stochastic terms}

This implies the deterministic equation: \frac{dx}{dt} = \alpha - \gamma x

This perfectly matches the deterministic model from Chapter 1 when we identify the molecule count as n = \Omega x.

The first order terms provide the stochastic dynamics:

First Order to Fokker-Planck Bridge

Collecting the O(\Omega^{-1/2}) terms from our systematic expansion:

From production: -\beta \frac{1}{\sqrt{\Omega}}\frac{\partial P}{\partial \eta} = -\Omega\alpha \frac{1}{\sqrt{\Omega}}\frac{\partial P}{\partial \eta}

From degradation: \gamma \sqrt{\Omega}\eta \frac{1}{\sqrt{\Omega}}\frac{\partial P}{\partial \eta} = \gamma \eta \frac{\partial P}{\partial \eta}

The O(\Omega^{-1/2}) equation becomes: \frac{\partial P}{\partial t} = \left[-\sqrt{\Omega}\alpha + \gamma \eta\right]\frac{\partial P}{\partial \eta} + \frac{1}{2}(\alpha + \gamma x)\Omega^{-1/2}\frac{\partial^2 P}{\partial \eta^2}

Transforming back to the original variable n and combining with the deterministic part gives the Fokker-Planck equation: \frac{\partial P(n,t)}{\partial t} = -\frac{\partial}{\partial n}[(\beta - \gamma n)P(n,t)] + \frac{1}{2}\frac{\partial^2}{\partial n^2}[(\beta + \gamma n)P(n,t)]

The first term is the deterministic drift, while the second term captures the diffusion due to molecular noise.

This equation, while continuous, still describes the evolution of the probability distribution P(n,t). A more intuitive representation is the equivalent Langevin Equation, which describes the trajectory of a single particle n(t) subject to deterministic drift and random kicks: \boxed{\frac{dn}{dt} = (\beta - \gamma n) + \sqrt{\beta + \gamma n} \cdot \zeta(t)} This is the Chemical Langevin Equation (CLE). This is a significant result—it looks just like our original ODE, but with an added noise term.

  • The drift term, (\beta - \gamma n), is identical to our deterministic ODE. It pulls the system toward the mean.
  • The diffusion term, \sqrt{\beta + \gamma n} \cdot \zeta(t), represents stochastic fluctuations. \zeta(t) is a “white noise” term, representing a series of uncorrelated random kicks. The magnitude of the noise depends on the current state of the system, n.

This derivation provides the formal justification for adding noise to ODEs. The general rule is that for any set of reactions, the drift term of the CLE is the sum of the reaction propensities (with appropriate signs), and the diffusion term is the square root of the sum of the propensities, multiplied by noise.

2.6.1.1 The General Chemical Langevin Equation

For a system with arbitrary reactions (using the notation from our CME derivation), the Chemical Langevin Equation takes the general form:

\boxed{\frac{d\mathbf{n}}{dt} = \sum_j \boldsymbol{\nu}_j a_j(\mathbf{n}) + \sum_j \boldsymbol{\nu}_j \sqrt{a_j(\mathbf{n})} \cdot \zeta_j(t)}

where: - \mathbf{n} is the state vector of molecule counts - a_j(\mathbf{n}) is the propensity function for reaction j - \boldsymbol{\nu}_j is the stoichiometric vector for reaction j - \zeta_j(t) are independent white noise processes

For our constitutive gene example with reactions \emptyset \xrightarrow{\beta} \text{protein} and \text{protein} \xrightarrow{\gamma} \emptyset, we have \boldsymbol{\nu}_1 = +1, \boldsymbol{\nu}_2 = -1, a_1(\mathbf{n}) = \beta, and a_2(\mathbf{n}) = \gamma n, which recovers our specific equation.

2.6.1.2 Connection to General Stochastic Differential Equations

The CLE is a special case of the general Stochastic Differential Equation (SDE): dx = f(x,t)dt + g(x,t)dW(t) where f(x,t) is the drift function, g(x,t) is the diffusion function, and W(t) is a Wiener process (Brownian motion).

To simulate SDEs, we use the Euler-Maruyama method: x(t + dt) = x(t) + f(x(t),t)dt + g(x(t),t) \cdot N(0,1)\sqrt{dt} where N(0,1) is a random number drawn from a standard normal distribution.

For our constitutive gene example, f(n,t) = \beta - \gamma n and g(n,t) = \sqrt{\beta + \gamma n}, giving: n(t + dt) = n(t) + (\beta - \gamma n(t))dt + \sqrt{\beta + \gamma n(t)} \cdot N(0,1)\sqrt{dt}

Just as we can study the CME for probability distributions or use Gillespie for sample paths, SDEs offer two complementary approaches: path-wise simulations (like Euler-Maruyama, analogous to Gillespie) or studying the evolution of probability densities using the Fokker-Planck equation (analogous to the CME). The general Fokker-Planck equation for an SDE with drift f(x,t) and diffusion g(x,t) is:

\frac{\partial P(x,t)}{\partial t} = -\frac{\partial}{\partial x}[f(x,t)P(x,t)] + \frac{1}{2}\frac{\partial^2}{\partial x^2}[g^2(x,t)P(x,t)]

We actually encountered this equation earlier in our system size expansion derivation. While we won’t explore Fokker-Planck methods further in this course, this framework provides powerful tools for analyzing stochastic biological systems beyond what we’ll cover here.

It is important to remember that this continuous approximation is valid only when molecule numbers are sufficiently large, such that the discrete jumps are small relative to the total number of molecules.

2.6.1.3 Code: SDE vs. Gillespie

Let’s see how well our new SDE approximation compares to an exact Gillespie simulation for the constitutive gene. We expect the SDE to be a good approximation when the average number of molecules is high.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

# (We assume gillespie_constitutive is defined as in the previous section)
def gillespie_constitutive(beta, gamma, t_final, n_initial=0):
    t = 0.0
    n = n_initial
    t_history = [t]
    n_history = [n]
    while t < t_final:
        a_prod = beta
        a_deg = gamma * n
        a_total = a_prod + a_deg
        if a_total == 0: break
        r1, r2 = np.random.random(2)
        tau = -np.log(r1) / a_total
        if r2 * a_total < a_prod:
            n += 1
        else:
            n = max(0, n - 1)
        t += tau
        t_history.append(t)
        n_history.append(n)
    return np.array(t_history), np.array(n_history)


def sde_constitutive(beta, gamma, t_final, n_initial=0, dt=0.01):
    """Simulate constitutive gene expression using the Euler-Maruyama method for the Langevin equation."""
    t_steps = int(t_final / dt)
    times = np.linspace(0, t_final, t_steps)
    n_history = np.zeros(t_steps)
    n_history[0] = n_initial
    
    sqrt_dt = np.sqrt(dt)

    for i in range(1, t_steps):
        n = n_history[i-1]
        
        # Prevent n from going negative, which can happen in the approximation
        n = max(0, n)

        # Deterministic drift
        drift = beta - gamma * n
        
        # Stochastic diffusion
        diffusion = np.sqrt(beta + gamma * n)
        
        # Update step
        n_history[i] = n + drift * dt + diffusion * np.random.normal(0, 1) * sqrt_dt

    return times, n_history

# Parameters
beta = 20.0
gamma = 0.5
mean_n = beta / gamma # Average molecule count = 40
t_final = 100.0
np.random.seed(42)

# --- Panel A: Single Trajectories ---
fig, (ax1, ax2) = plt.subplots(1, 2)

# Gillespie trajectory
t_g, n_g = gillespie_constitutive(beta, gamma, t_final, n_initial=mean_n)
ax1.step(t_g, n_g, where='post', color=QUALITATIVE_COLORS[0], alpha=0.8, linewidth=1.5, label='Gillespie (Exact)')

# SDE trajectory
t_sde, n_sde = sde_constitutive(beta, gamma, t_final, n_initial=mean_n, dt=0.1)
ax1.plot(t_sde, n_sde, color=QUALITATIVE_COLORS[1], alpha=0.8, linewidth=1.5, label='SDE (Approx.)')

ax1.axhline(mean_n, color='gray', linestyle='--', label=f'Mean ({mean_n:.0f})')
ax1.set_xlabel('Time')
ax1.set_ylabel('Molecule Count (n)')
ax1.set_title('(a) Single Trajectory Comparison')
ax1.legend()
ax1.grid(True, alpha=0.3)

# --- Panel B: Steady-State Distributions ---
n_sims = 2500
final_counts_g = []
final_counts_sde = []

for i in range(n_sims):
    _, n_g_run = gillespie_constitutive(beta, gamma, t_final)
    final_counts_g.append(n_g_run[-1])
    
    _, n_sde_run = sde_constitutive(beta, gamma, t_final)
    final_counts_sde.append(n_sde_run[-1])

# Plot histograms
max_val = max(np.max(final_counts_g), np.max(final_counts_sde))
bins = np.linspace(0, max_val, 40)
ax2.hist(final_counts_g, bins=bins, density=True, color=QUALITATIVE_COLORS[0], alpha=0.6, edgecolor='none', label='Gillespie')
ax2.hist(final_counts_sde, bins=bins, density=True, color=QUALITATIVE_COLORS[1], alpha=0.6, edgecolor='none', label='SDE')

# Overlay theoretical Poisson for reference
x_poisson = np.arange(0, max_val)
y_poisson = poisson.pmf(x_poisson, mu=mean_n)
ax2.plot(x_poisson, y_poisson, 'k-', linewidth=2, label='Poisson (Theory)')

ax2.set_xlabel('Molecule Count (n)')
ax2.set_ylabel('Probability')
ax2.set_title('(b) Steady-State Distributions')
ax2.legend()
ax2.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()
Figure 2.14: Comparison of the continuous SDE approximation (red) and the exact discrete Gillespie simulation (blue) for the constitutive gene model. (a) A single trajectory from each method shows that the SDE closely tracks the general behavior of the Gillespie simulation, capturing the fluctuations around the mean. (b) The steady-state probability distributions generated from many simulations show excellent agreement, confirming that the Langevin equation is a valid and accurate approximation when molecule numbers are sufficiently high.

The close match between the exact Gillespie simulation and the SDE approximation confirms that the Langevin equation is a powerful and accurate tool. It is computationally much faster than the Gillespie algorithm, as it takes fixed time steps dt rather than simulating every single reaction event. This efficiency becomes critical when we move to more complex systems.

But the SDE’s validity rests on a crucial assumption: that the number of molecules is large enough for the system to be considered continuous. This is the core of the system size expansion we used to derive it. What happens when this assumption is violated? Let’s test the limits of the approximation by exploring a low-copy-number regime, where the random fluctuations are on the same order as the mean itself.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def gillespie_constitutive(beta, gamma, t_final, n_initial=0):
    """Simulate constitutive gene expression using Gillespie algorithm."""
    t = 0.0
    n = n_initial
    t_history = [t]
    n_history = [n]
    while t < t_final:
        a_prod = beta
        a_deg = gamma * n
        a_total = a_prod + a_deg
        if a_total == 0: break
        r1, r2 = np.random.random(2)
        tau = -np.log(r1) / a_total
        if r2 * a_total < a_prod:
            n += 1
        else:
            n = max(0, n - 1)
        t += tau
        t_history.append(t)
        n_history.append(n)
    return np.array(t_history), np.array(n_history)

def sde_constitutive(beta, gamma, t_final, n_initial=0, dt=0.01):
    """Simulate constitutive gene expression using the Euler-Maruyama method for the Langevin equation."""
    t_steps = int(t_final / dt)
    times = np.linspace(0, t_final, t_steps)
    n_history = np.zeros(t_steps)
    n_history[0] = n_initial
    sqrt_dt = np.sqrt(dt)
    for i in range(1, t_steps):
        n = n_history[i-1]
        # SDE can go negative, but for diffusion term, we need n>=0
        n_for_diffusion = max(0, n)
        drift = beta - gamma * n
        diffusion = np.sqrt(beta + gamma * n_for_diffusion)
        n_history[i] = n + drift * dt + diffusion * np.random.normal(0, 1) * sqrt_dt
    return times, n_history

# Parameters for low copy number regime to emphasize SDE breakdown
beta_low = 1.5
gamma_low = 1.0
mean_n_low = beta_low / gamma_low # Average molecule count = 1.5
t_final_low = 50.0
np.random.seed(50)

# --- Panel A: Single Trajectories ---
fig, (ax1, ax2) = plt.subplots(1, 2)

# Gillespie trajectory
t_g, n_g = gillespie_constitutive(beta_low, gamma_low, t_final_low, n_initial=mean_n_low)
ax1.step(t_g, n_g, where='post', color=QUALITATIVE_COLORS[0], alpha=0.8, linewidth=1.5, label='Gillespie (Discrete)')

# SDE trajectory
t_sde, n_sde = sde_constitutive(beta_low, gamma_low, t_final_low, n_initial=mean_n_low, dt=0.05)
ax1.plot(t_sde, n_sde, color=QUALITATIVE_COLORS[1], alpha=0.8, linewidth=1.5, label='SDE (Continuous)')

ax1.axhline(0, color='gray', linestyle='--', label='Zero')
ax1.set_xlabel('Time')
ax1.set_ylabel('Molecule Count (n)')
ax1.set_title('(a) Trajectory Comparison')
ax1.legend()
ax1.grid(True, alpha=0.3)

# --- Panel B: Steady-State Distributions ---
n_sims = 10000
final_counts_g = []
final_counts_sde = []

for i in range(n_sims):
    _, n_g_run = gillespie_constitutive(beta_low, gamma_low, t_final_low)
    final_counts_g.append(n_g_run[-1])

    _, n_sde_run = sde_constitutive(beta_low, gamma_low, t_final_low, dt=0.05)
    # DO NOT reflect negative values. Show the raw SDE output to demonstrate breakdown.
    final_counts_sde.append(n_sde_run[-1])

# Plot histograms
# Define bins to capture both negative and positive values
min_val = int(np.min(final_counts_sde)) - 1
max_val = int(max(np.max(final_counts_g), np.percentile(final_counts_sde, 99)))
bins = np.linspace(min_val - 0.5, max_val + 1.5, max_val - min_val + 4)
ax2.hist(final_counts_g, bins=bins, density=True, color=QUALITATIVE_COLORS[0], alpha=0.6, edgecolor='none', label='Gillespie')
ax2.hist(final_counts_sde, bins=bins, density=True, color=QUALITATIVE_COLORS[1], alpha=0.6, edgecolor='none', label='SDE (Uncorrected)')

# Overlay theoretical Poisson
x_poisson = np.arange(0, max_val + 1)
y_poisson = poisson.pmf(x_poisson, mu=mean_n_low)
ax2.plot(x_poisson, y_poisson, 'ko-', markersize=4, linewidth=2, label='Poisson (Theory)')

ax2.set_xlabel('Molecule Count (n)')
ax2.set_ylabel('Probability')
ax2.set_title('(b) Distribution Comparison')
ax2.legend()
ax2.grid(True, alpha=0.3)
ax2.set_xlim(min_val, max_val + 1)
ax2.axvline(0, color='black', linestyle='--', alpha=0.5)

plt.tight_layout()
plt.show()
Figure 2.15: Breakdown of the SDE approximation at low copy numbers. (a) A single trajectory comparison shows the continuous SDE (red) dipping into unphysical negative values, while the discrete Gillespie simulation (blue) correctly remains non-negative. (b) The steady-state distribution from the SDE, shown with its unphysical negative values (left of the dashed line), fails to match the true Poisson distribution from the exact Gillespie algorithm. The SDE’s continuous nature allows it to cross the zero boundary, a clear sign of its breakdown when discrete molecular jumps are large relative to the mean.
Worked Example: The Stochastic Landscape of the Toggle Switch

2.6.1.4 The Toggle Switch Revisited: A Dynamic Landscape

Now we can return to the genetic toggle switch and apply our rigorous SDE framework. This will allow us to properly simulate the “stochastic landscape” we alluded to at the end of Chapter 1.

The toggle switch consists of two proteins, n₁ and n₂, that mutually repress each other. The reactions for n₁ are: 1. Production: ∅ → n₁ with rate α / (1 + (n₂/K)ⁿ). 2. Degradation: n₁ → ∅ with rate γn₁.

Applying the Langevin recipe, the SDE for n₁ becomes:

\frac{dn_1}{dt} = \underbrace{\left(\frac{\alpha}{1 + (n_2/K)^n} - \gamma n_1\right)}_{\text{Drift}} + \underbrace{\sqrt{\frac{\alpha}{1 + (n_2/K)^n} + \gamma n_1}}_{\text{Diffusion}} \cdot \zeta_1(t)

The equation for n₂ is symmetric. Notice a key feature: the noise term for n₁ depends on the amount of n₂. This is called multiplicative noise, and it means the landscape itself is dynamic. The roughness of the terrain your cell is exploring for the n₁ dimension depends on where it is in the n₂ dimension. This coupling of noise sources is what creates the rich, complex dynamics of the stochastic landscape.

2.6.1.5 Stochastic Landscapes in Action

Let’s simulate these coupled SDEs. To visualize this landscape, we choose parameters that create two stable states but with a barrier that is low enough for noise-induced switching to be observable within our simulation time. This is achieved by using a moderate level of cooperativity. We will start a cell in one of the stable states (e.g., high n₁, low n₂) and watch its trajectory. Because of the stochastic term, the cell will not stay fixed at the attractor. Instead, it will jiggle around inside the valley. If we wait long enough, a particularly large sequence of random kicks can push the cell over the saddle point and into the other valley—a noise-induced state switch.

By running a long simulation and plotting the density of where the system spent its time, we can reconstruct the “effective landscape” that the cell explores. The valleys of this landscape correspond to the stable states of our deterministic model, but now they are connected by the paths forged by noise.

Code
import numpy as np
import matplotlib.pyplot as plt

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def sde_toggle_switch(alpha, n_coop, K, gamma, t_final, n_initial, dt=0.1):
    """Simulate the toggle switch using coupled SDEs."""
    t_steps = int(t_final / dt)
    times = np.linspace(0, t_final, t_steps)
    n_history = np.zeros((t_steps, 2))
    n_history[0, :] = n_initial
    
    sqrt_dt = np.sqrt(dt)

    for i in range(1, t_steps):
        n1, n2 = n_history[i-1, :]
        n1, n2 = max(0, n1), max(0, n2)

        # Drifts
        drift1 = alpha / (1 + (n2 / K)**n_coop) - gamma * n1
        drift2 = alpha / (1 + (n1 / K)**n_coop) - gamma * n2

        # Diffusions
        prod1_rate = alpha / (1 + (n2 / K)**n_coop)
        deg1_rate = gamma * n1
        diffusion1 = np.sqrt(prod1_rate + deg1_rate)

        prod2_rate = alpha / (1 + (n1 / K)**n_coop)
        deg2_rate = gamma * n2
        diffusion2 = np.sqrt(prod2_rate + deg2_rate)
        
        # Random numbers for this step
        W1, W2 = np.random.normal(0, 1, 2)

        # Update step
        n_history[i, 0] = n1 + drift1 * dt + diffusion1 * W1 * sqrt_dt
        n_history[i, 1] = n2 + drift2 * dt + diffusion2 * W2 * sqrt_dt
        
    return times, n_history

# Parameters for bistability
alpha = 50.0
gamma = 1.0
n_coop = 2.5  # Lower cooperativity to reduce the barrier height
K = 25.0     # Slightly increase K to adjust fixed point locations
t_final = 500.0  # Increase simulation time to ensure switches are observed
dt = 0.05    # Decrease timestep for better numerical stability
np.random.seed(101)

# --- Panel A: Long Trajectory ---
fig, (ax1, ax2) = plt.subplots(1, 2)
t_sde, n_sde = sde_toggle_switch(alpha, n_coop, K, gamma, t_final, n_initial=[50, 5], dt=dt)

ax1.plot(t_sde, n_sde[:, 0], color=QUALITATIVE_COLORS[0], alpha=0.8, label='Protein 1')
ax1.plot(t_sde, n_sde[:, 1], color=QUALITATIVE_COLORS[1], alpha=0.8, label='Protein 2')
ax1.set_ylim([0, 75])
ax1.set_xlabel('Time')
ax1.set_ylabel('Molecule Count')
ax1.set_title('(a) Noise-Induced State Switching')
ax1.legend()
ax1.grid(True, alpha=0.3)

# --- Panel B: Reconstructed Landscape ---
# Use a 2D histogram to visualize the probability density
hist, x_edges, y_edges = np.histogram2d(
    n_sde[:, 0], n_sde[:, 1],
    bins=50, range=[[0, 80], [0, 80]], density=True
)

# Convert density to a potential U = -log(P)
potential = -np.log(hist.T + 1e-7)
potential = potential - np.min(potential)

# Plot the landscape (reversed colormap so low values are "hot" for quasi-potential)
X, Y = np.meshgrid(x_edges[:-1], y_edges[:-1])
contour = ax2.contourf(X, Y, potential, levels=20, cmap='plasma_r')
plt.colorbar(contour, ax=ax2, label='Potential U = -log(P)')

# Overlay the trajectory
ax2.plot(n_sde[::10, 0], n_sde[::10, 1], color='white', alpha=0.3, linewidth=0.5)

# Overlay the nullclines from Chapter 1 (use different colors than panel a)
p_range = np.linspace(0, 80, 200)
nullcline_1 = alpha / (gamma * (1 + (p_range / K)**n_coop))
ax2.plot(nullcline_1, p_range, '--', color=QUALITATIVE_COLORS[2], linewidth=2, label='n1 Nullcline')
ax2.plot(p_range, nullcline_1, '--', color=QUALITATIVE_COLORS[5], linewidth=2, label='n2 Nullcline')

ax2.set_xlabel('Protein 1 Count')
ax2.set_ylabel('Protein 2 Count')
ax2.set_title('(b) Reconstructed Stochastic Landscape')
ax2.set_xlim(0, 75)
ax2.set_ylim(0, 75)
ax2.legend()

plt.tight_layout()
plt.show()
Figure 2.16: The stochastic toggle switch landscape. (a) A long SDE trajectory shows the system dwelling in one of two stable states (valleys) but occasionally using noise to jump between them. (b) The probability distribution from the simulation, plotted as a potential landscape (U = -log P), reveals the two basins of attraction. The deterministic nullclines (dashed lines) from Chapter 1 correctly predict the locations of the valleys, but only the stochastic simulation reveals the paths connecting them.

This figure is the culmination of our journey. The landscape, which was a static, abstract metaphor in Chapter 1, has now been realized as a dynamic reality. We can see the valleys of stability, but we can also see the noisy paths that connect them. This brings the abstract Waddington landscape to life, explicitly connecting the SDE results—the populated valleys and the paths between them—to the deterministic framework that predicts the valley locations through nullclines and fixed points. This SDE framework gives us a computationally efficient way to explore these dynamics for complex networks where Gillespie simulations would be too slow.

2.6.2 Direct Numerical Solution (Finite State Projection)

While stochastic simulation gives us sample trajectories and steady-state analysis provides specific solutions, sometimes we need the full time-dependent probability distribution P(n,t). This section explores computational approaches for directly solving the Chemical Master Equation.

2.6.2.1 Finite State Projection: Making the CME Tractable

While the Chemical Master Equation is theoretically exact, its infinite dimensionality makes direct numerical solution impossible. The Finite State Projection (FSP) method (Munsky and Khammash 2006) makes the problem tractable by exploiting the fact that molecule numbers often remain bounded.

The core idea is to truncate the infinite state space to a finite set of states {0, 1, \ldots, N} and solve the dynamics within this bounded space:

  1. Truncate the state space: Consider only states n = 0, 1, 2, \ldots, N
  2. Modify the boundary: Set the rate of transitions from state N to N+1 to zero
  3. Solve numerically: The result is a finite system of N+1 linear ODEs that can be solved efficiently

This transforms the infinite-dimensional problem into a finite system of linear ODEs that can be written in matrix form as \frac{d\mathbf{P}}{dt} = \mathbf{A}\mathbf{P}, where \mathbf{P} = [P(0), P(1), \ldots, P(N)]^T and \mathbf{A} is the transition matrix encoding the reaction network.

Worked Example: FSP for the Constitutive Gene

For our constitutive gene example, the truncated CME becomes:

\frac{dP(0,t)}{dt} = \gamma P(1,t) - \beta P(0,t) \frac{dP(n,t)}{dt} = \beta P(n-1,t) + \gamma(n+1)P(n+1,t) - (\beta + \gamma n)P(n,t) \quad n = 1, \ldots, N-1 \frac{dP(N,t)}{dt} = \beta P(N-1,t) - \gamma N \cdot P(N,t)

This system of N+1 linear ODEs can be solved using standard numerical methods, providing the full probability distribution without the need for stochastic simulation.

We can write this system in matrix form where \mathbf{A} is the tridiagonal transition matrix:

\mathbf{A} = \begin{pmatrix} -\beta & \gamma & 0 & 0 & \cdots & 0 \\ \beta & -(\beta + \gamma) & 2\gamma & 0 & \cdots & 0 \\ 0 & \beta & -(\beta + 2\gamma) & 3\gamma & \cdots & 0 \\ \vdots & \ddots & \ddots & \ddots & \ddots & \vdots \\ 0 & \cdots & 0 & \beta & -(\beta + (N-1)\gamma) & N\gamma \\ 0 & \cdots & 0 & 0 & \beta & -N\gamma \end{pmatrix}

This tridiagonal structure reflects the birth-death nature of the constitutive gene: the sub-diagonal contains production rates \beta, the super-diagonal contains degradation rates n\gamma, and the main diagonal contains the negative exit rates from each state.

Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
from scipy.stats import poisson
from matplotlib.colors import LogNorm

# GeoDataViz Qualitative Palette
QUALITATIVE_COLORS = ['#FF1F5B', '#009ADE', '#AF58BA', '#FFC61E', '#F28522', '#00CD6C']

def fsp_constitutive_ode(P, t, beta, gamma, N):
    """
    ODE system for FSP truncation of constitutive gene CME
    """
    dPdt = np.zeros(N+1)
    
    # n = 0: can only gain from n=1, lose by production
    dPdt[0] = gamma * P[1] - beta * P[0]
    
    # n = 1 to N-1: standard CME logic
    for n in range(1, N):
        dPdt[n] = beta * P[n-1] + gamma * (n+1) * P[n+1] - (beta + gamma * n) * P[n]
    
    # n = N (boundary): can gain from N-1, but cannot produce more.
    # The production term that would go to N+1 is removed.
    dPdt[N] = beta * P[N-1] - gamma * N * P[N]
    
    return dPdt

# Parameters
beta, gamma = 10, 2
mean_expected = beta / gamma
N = int(mean_expected + 6*np.sqrt(mean_expected))  # Truncation level

# Time points
t_points = np.linspace(0, 10, 100)

# Initial condition: all probability at n=0
P0 = np.zeros(N+1)
P0[0] = 1.0

# Solve FSP system
solution = odeint(fsp_constitutive_ode, P0, t_points, args=(beta, gamma, N))

fig, (ax1, ax2) = plt.subplots(2, 1)

# Panel A: Time evolution of distribution (time on x-axis)
n_states = np.arange(N+1)
T, X = np.meshgrid(t_points, n_states[:20])  # Show first 20 states, time on x
Z = solution[:, :20].T  # Transpose for flipped axes

# Use log scale for better visualization of small probabilities
# Clip data to minimum value to prevent colorbar from extending below threshold
vmin = 1e-7
Z_clipped = np.clip(Z, vmin, Z.max())
im = ax1.contourf(T, X, Z_clipped, levels=25, cmap='plasma', norm=LogNorm(vmin=vmin, vmax=Z.max()))
ax1.set_xlabel('Time')
ax1.set_ylabel('Molecule Count (n)')
ax1.set_title('(a) FSP: Numerical Distribution Evolution')
plt.colorbar(im, ax=ax1, label='Probability P(n,t)')

# Panel B: Steady state comparison
P_steady = solution[-1, :]  # Final time point

# Gillespie comparison (final counts from previous simulation)
final_counts = []
n_sims = 5000
np.random.seed(42)
for _ in range(n_sims):
    times, counts = gillespie_constitutive(beta, gamma, 20)
    final_counts.append(counts[-1])

# Plot comparison
n_vals = np.arange(min(N+1, 25))

# Gillespie as histogram (bars)
bins = np.arange(0, max(n_vals)+2) - 0.5
hist_counts, _ = np.histogram(final_counts, bins=bins, density=True)
ax2.bar(n_vals, hist_counts[:len(n_vals)], alpha=0.7, color='gray',
        label='Gillespie simulation', width=0.8, edgecolor='none')

# FSP as curve with staggered n values (offset slightly for visibility)
n_vals_fsp = n_vals + 0.2
ax2.plot(n_vals_fsp, P_steady[:len(n_vals)], 'o-', color=QUALITATIVE_COLORS[0],
         linewidth=2, markersize=6, label='FSP (numerical)')

# Analytical Poisson as curve with staggered n values (offset in opposite direction)
n_vals_poisson = n_vals - 0.05
poisson_probs = poisson.pmf(n_vals, mean_expected)
ax2.plot(n_vals_poisson, poisson_probs, 's-', color=QUALITATIVE_COLORS[1],
         linewidth=2, markersize=5, label='Analytical (Poisson)')

ax2.set_xlabel('Molecule Count (n)')
ax2.set_ylabel('Steady-State Probability')
ax2.set_title('(b) Method Comparison')
ax2.legend()
ax2.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()

# Check truncation accuracy
total_prob = np.sum(P_steady)
print(f"Total probability captured: {total_prob:.6f}")
print(f"Probability mass beyond N={N}: {1-total_prob:.6f}")
Figure 2.17: Finite State Projection provides exact numerical solution of the truncated CME. (a) Time evolution of the probability distribution computed using FSP shows the approach to steady state. (b) Comparison of FSP solution, Gillespie simulation, and analytical Poisson result demonstrates excellent agreement when the truncation captures sufficient probability mass.
Total probability captured: 1.000000
Probability mass beyond N=18: 0.000000

FSP is most valuable when you need the complete probability distribution for systems with few species (≤3), providing deterministic, error-bounded results ideal for studying phenomena like bimodality where simulations might be inefficient.

2.6.3 Analytical Approaches (Moment-Based Methods)

2.6.3.1 Moment Generating Functions: A Powerful Mathematical Tool

The moment generating function (MGF) provides a systematic way to characterize probability distributions and derive their moments. For a random variable X, the MGF is defined as:

M_X(s) = \langle e^{sX} \rangle = \sum_{n=0}^{\infty} P(n) e^{sn}

The moments can be obtained by taking derivatives: \langle X^k \rangle = \frac{d^k M_X}{ds^k}\big|_{s=0}.

MGF for the Constitutive Gene: The recurrence relation method worked well for the constitutive gene, but the MGF approach provides additional insight. Starting with the CME: \frac{dP(n,t)}{dt} = \beta P(n-1,t) + \gamma(n+1)P(n+1,t) - (\beta + \gamma n)P(n,t)

We define M(s, t) = \sum_{n=0}^{\infty} e^{sn} P(n,t) and multiply the CME by e^{sn}, summing over all n. After carefully handling the index shifts in the summations, this transforms the CME into a PDE for the MGF: \frac{\partial M(s,t)}{\partial t} = \beta(e^s - 1)M(s,t) + \gamma(e^{-s} - 1)\frac{\partial M(s,t)}{\partial s}

At steady state, \frac{\partial M}{\partial t} = 0, giving us the PDE: \beta(e^s - 1)M(s) + \gamma(e^{-s} - 1)\frac{dM(s)}{ds} = 0

The solution to this PDE is: M(s) = e^{\frac{\beta}{\gamma}(e^s - 1)}

This is exactly the MGF for a Poisson distribution with parameter \lambda = \beta/\gamma. We can find moments by differentiation:

  • Mean: \langle n \rangle = M'(0) = \beta/\gamma
  • Variance: \text{Var}(n) = M''(0) + M'(0) - [M'(0)]^2 = \beta/\gamma

MGFs are particularly powerful because they uniquely determine the distribution, provide compact expressions for moments, and facilitate analysis of sums of independent random variables. Even when we cannot solve the PDE for M(s,t) analytically, we can extract moment dynamics directly. Since \langle n^k \rangle = \frac{\partial^k M}{\partial s^k}\big|_{s=0}, differentiating our PDE \frac{\partial M}{\partial t} = \beta(e^s - 1)M + \gamma(e^{-s} - 1)\frac{\partial M}{\partial s} with respect to s and evaluating at s=0 gives moment equations. The first moment satisfies: \frac{d\langle n \rangle}{dt} = \left.\frac{\partial^2 M}{\partial s \partial t}\right|_{s=0} = \beta \langle 1 \rangle - \gamma \langle n \rangle = \beta - \gamma \langle n \rangle Taking the second derivative yields the equation for \langle n^2 \rangle: \frac{d\langle n^2 \rangle}{dt} = \left.\frac{\partial^3 M}{\partial s^2 \partial t}\right|_{s=0} = \beta(1 + 2\langle n \rangle) - 2\gamma \langle n^2 \rangle This approach extracts exact moment dynamics even for complex systems where the full MGF remains intractable.

2.6.3.2 The Moment Closure Problem: When Linearity Breaks Down

An alternative to solving the complete CME is to track only the moments of the distribution—the mean, variance, and higher-order statistics. This approach works perfectly for systems with linear propensities, but it breaks down for nonlinear systems, creating what is known as the moment closure problem.

The moment approach starts with the fundamental insight that the time evolution of any moment \langle n^k \rangle can be derived directly from the CME. For any function f(n), we have \frac{d\langle f(n) \rangle}{dt} = \sum_n f(n) \frac{dP(n,t)}{dt}. By substituting the CME and rearranging, this becomes \frac{d\langle f(n) \rangle}{dt} = \langle \Delta f \rangle, where \Delta f is the change in f due to each reaction, weighted by the reaction propensities.

Let’s first see an example of a closed system. Consider a simple negative autoregulation model where a protein represses its own synthesis. We can approximate this with a linearly decreasing production rate:

  • Production propensity: a(n) = \beta_0 - k \cdot n
  • Degradation propensity: d(n) = \gamma \cdot n

Applying our moment evolution formula with f(n) = n, the rate of change of the mean is the expected net change per unit time: \frac{d\langle n \rangle}{dt} = \langle (\beta_0 - k \cdot n) - (\gamma \cdot n) \rangle = \beta_0 - (k+\gamma)\langle n \rangle Because the propensities are linear in n, the equation for the first moment, \langle n \rangle, depends only on itself. We can solve this ODE directly. This is a closed system.

Now, let’s see how nonlinearity breaks this closure. We’ll use a model of negative autoregulation where the protein represses its own production through cooperative binding. The rate of production decreases proportionally to the number of possible protein dimers, which is n(n-1)/2.

  • Production propensity: a(n) = \alpha_0 - \frac{k}{2} n(n-1)
  • Degradation propensity: d(n) = \gamma n

The rate of change of the mean is now: \frac{d\langle n \rangle}{dt} = \left\langle \alpha_0 - \frac{k}{2} (n^2 - n) - \gamma n \right\rangle = \alpha_0 - \frac{k}{2}(\langle n^2 \rangle - \langle n \rangle) - \gamma \langle n \rangle The equation for the first moment, \langle n \rangle, now depends on the second moment, \langle n^2 \rangle. If we were to write an equation for \langle n^2 \rangle, we would find it depends on the third moment, \langle n^3 \rangle, and so on. This creates an infinite, unclosed hierarchy of equations.

This problem draws a fundamental distinction between types of biological circuits. Systems with at most linear reaction rates (like the constitutive gene and Telegraph model) often have closed or solvable moment dynamics. In contrast, systems with nonlinear rates (like most feedback loops) require approximation methods to “close” the hierarchy, for example by assuming the third moment can be expressed in terms of the first two. The closure problem is precisely why the same biological mechanism—positive feedback—posed no analytical challenges in Chapter 1’s deterministic framework but becomes mathematically intractable in the stochastic setting without further approximation.

Worked Example: MGF for the Bursting Model

Here, we’ll derive the steady-state distribution for the phenomenological bursting model. This is a cornerstone result in stochastic gene expression.

The Model: 1. mRNA bursts are produced as a Poisson process with rate \alpha. 2. The number of molecules in each burst follows a Geometric distribution with mean b. 3. mRNA molecules decay independently with rate \gamma.

The Goal: We want to find the MGF for the total number of mRNA molecules, N, at steady state.

Step 1: The Master Equation

Let P(n) be the probability of having n mRNA molecules. The steady-state master equation is: 0 = \underbrace{\gamma \left( (n+1)P(n+1) - nP(n) \right)}_{\text{Degradation}} + \underbrace{\alpha \left( \sum_{j=0}^{n} P_{burst}(j)P(n-j) - P(n) \right)}_{\text{Bursty Production}} where P_{burst}(j) is the probability of a burst of size j.

Step 2: The MGF Equation

Let’s define the MGF as M(s) = \sum_{n=0}^{\infty} e^{sn} P(n). The MGF for the burst size distribution is M_B(s) = \sum_{j=0}^{\infty} e^{sj} P_{burst}(j). The master equation can be converted into an ODE for M(s): \frac{dM}{dt} = \gamma(e^{-s}-1)\frac{dM}{ds} + \alpha(M_B(s)-1)M(s) At steady state, \frac{dM}{dt} = 0, which gives: \gamma(1-e^{-s})\frac{dM}{ds} = \alpha(M_B(s)-1)M(s)

Step 3: Solve for the MGF

The burst size is geometrically distributed with mean b. The PMF is P_{burst}(j) = \frac{1}{b+1} \left(\frac{b}{b+1}\right)^j. Its MGF is M_B(s) = \frac{1}{1+b-be^s}.

Substituting M_B(s) into the steady-state equation: \alpha(M_B(s)-1) = \alpha\left(\frac{1 - (1+b-be^s)}{1+b-be^s}\right) = \alpha\left(\frac{b(e^s-1)}{1+b-be^s}\right) And so: \gamma(1-e^{-s})\frac{dM}{ds} = \alpha \frac{b(e^s-1)}{1+b-be^s} M(s) Noting that 1-e^{-s} = \frac{e^s-1}{e^s}, we can simplify: \frac{dM}{M} = \frac{\alpha b}{\gamma} \frac{e^s}{1+b-be^s} ds Integrating both sides gives: \ln(M(s)) = -\frac{\alpha}{\gamma} \ln(1+b-be^s) + C Using the condition M(0)=1, we find the integration constant C=0. M(s) = (1+b-be^s)^{-\alpha/\gamma}

Step 4: Show Negative Binomial Form

Let’s rearrange this into the standard form for a Negative Binomial MGF, M(s) = \left(\frac{p}{1-(1-p)e^s}\right)^r.

Define the parameters:

  • r = \alpha/\gamma (the ratio of burst production to degradation)
  • p = \frac{1}{1+b} (the success probability, related to burst size)

Then 1-p = \frac{b}{1+b}. Substituting these into our solution: M(s) = \left(\frac{1}{p} - \frac{1-p}{p}e^s\right)^{-r} = \left(\frac{1-(1-p)e^s}{p}\right)^{-r} = \left(\frac{p}{1-(1-p)e^s}\right)^r This is exactly the MGF for a Negative Binomial distribution.

Conclusion: The steady-state distribution of mRNA produced in random bursts is a Negative Binomial distribution. The parameters of this distribution, r and p, are directly related to the physical parameters of the system: the effective burst frequency (\alpha/\gamma) and the mean burst size (b). This provides a powerful link between a simple phenomenological model and experimentally observable distributions.

2.7 Conclusion: From Forward Models to Inverse Challenges

In this chapter, we journeyed from a fundamental experimental puzzle—the noisy expression of genes in identical cells—to a powerful suite of predictive models. We saw that a purely deterministic view was not enough. To capture biological reality, we had to embrace probability, exploring frameworks at three complementary scales. We moved from the macroscopic world of ODEs, which describes smooth averages, to the microscopic world of the Gillespie algorithm, which simulates every discrete molecular event. Bridging these two extremes, we found the mesoscopic view of stochastic differential equations, which systematically reintroduced noise into our continuous models and brought the Waddington landscape to life.

Across all these scales, we have been solving the forward problem: given a model and its parameters (like the rates of transcription and gene switching), we can predict the system’s behavior. We can generate the bursting statistics and the full probability distributions we expect to see in an experiment.

But in the lab, we face the opposite challenge. We have the data—a distribution of mRNA counts from an scRNA-seq experiment—but we don’t know the underlying parameters that generated it. This is the inverse problem, and it is the central challenge of quantitative biology.

When we look at real single-cell data, our Telegraph model tells us that the observed noise is caused by transcriptional bursting. But it doesn’t tell us the specific parameters for each gene. Is a gene’s expression pattern the result of frequent, small bursts or rare, large ones? Is its promoter almost always on, or does it flicker on and off rapidly? Answering these questions requires us to infer the hidden parameters from the data we can measure.

This is the inverse problem: given the experimental data, can we deduce the model parameters that created it? This challenge—of fitting models to messy, incomplete, and noisy biological data—is where our theoretical models meet the real world. And it is the subject of our next chapter.