Chemical Master Equation¤
Exact Chemical Master Equation solver via matrix exponentiation.
For time-independent reaction systems with finite (or finitely truncated) state spaces, the probability distribution \(P(t)\) evolves according to:
where \(Q\) is the generator (rate) matrix. The exact solution is:
This module provides utilities to:
- Build the generator matrix \(Q\) from a
MassActionJumpproblem on a truncated state space - Solve the CME exactly using matrix exponentiation
Functions¤
jumpax.build_generator(problem: jumpax.MassActionJump, max_counts: Int[Array, 'S'], *, args: PyTree[Any] = None, t0: float = 0.0) -> tuple
¤
Build the generator matrix Q for a jumpax.MassActionJump on a
truncated state space.
The state space is the rectangular lattice \(\{0, ..., \text{max\_counts}_i\}\) for each species \(i\). Transitions leaving this box are dropped.
Arguments:
problem: Ajumpax.MassActionJumpdefining the reaction systemmax_counts: array of maximum population per speciesargs: Optional arguments passed to rate functiont0: Time at which to evaluate rates (only matters for time-dependent rates)
Returns:
Q: generator matrix where N = prod(max_counts + 1)cme_state: CMEState containing state space information
jumpax.solve_cme(Q: Float[Array, 'N N'], p0: Float[Array, 'N'], t: float) -> Float[Array, 'N']
¤
Solve the CME exactly via matrix exponentiation.
Computes \(P(t) = \exp(Q t) P(0)\).
Arguments:
Q: generator matrix fromjumpax.build_generatorp0: initial probability distribution (should sum to 1)t: Time at which to evaluate the distribution
Returns:
p_t: probability distribution at time t
jumpax.marginal_distribution(p: Float[Array, 'N'], cme_state: jumpax.CMEState, species: int) -> Float[Array, 'M']
¤
Compute the marginal distribution for a single species.
Arguments:
p: probability distribution over statescme_state: State space informationspecies: Index of species to marginalize over
Returns:
marginal: marginal distribution where M = max_counts[species] + 1
Types¤
jumpax.CMEState
¤
State space information for Chemical Master Equation (CME) solver.
Attributes:
| Name | Type | Description |
|---|---|---|
states |
array of all states in the truncated state space |
|
strides |
array for mixed-radix encoding |
|
max_counts |
array of maximum count per species |