4. API Reference
The entire public API is provided by the
SymbolicCompartmentalModel
class. The list below covers the most commonly used members; click any entry
to jump to its full documentation.
4.1. Model setup
SymbolicCompartmentalModel(n_states)Constructor — create a new model with n_states compartments.
contributed_turnoversGet / set the rate matrix M (n_states × n_states).
M[i, j]is the transfer rate from state j into state i; diagonal entries must be ≤ 0.observed_pool_weightsGet / set the fractional weights of the observed pools (must sum to 1).
growth_rateGet / set the dilution rate µ (added to all diagonal entries during computation).
add_parameter(symbol, lb, ub)Register a free symbolic parameter with lower and upper bounds for later fitting.
4.2. Simulation and symbolic analysis
as_symbolic(key)Return a SymPy expression for any dynamic attribute (e.g.
"f","mean_age","mean_residence_time").as_numeric(key)Return a numeric scalar, array, or callable for any dynamic attribute.
4.3. Fitting
fit(tdata, ydata)Fit the model to a single labeling time series using basin-hopping global optimisation.
fit_multiple_pools(data)Fit a single model to labeling data from multiple pools simultaneously.
estimate_mean_age_trapezoid(tdata, ydata)Model-free estimate of mean age by numerical integration of the labeling curve.
estimate_mean_residence_time_trapezoid(tdata, ydata, mu)Model-free estimate of mean residence time by numerical integration.
4.4. Visualization
plot(key)Plot any dynamic attribute over a time range on a matplotlib axes.
draw_transition_matrix()Draw the compartment network as a directed graph.