simulations
pfi.utils.simulations
Simulation utilities for benchmark dynamical systems.
g_rate(x1, x2, gr)
Compute the cell growth rate used in the toggle-switch simulator.
Parameters:
-
x1(ndarray of shape (n_samples,)) –First coordinate of the state.
-
x2(ndarray of shape (n_samples,)) –Second coordinate of the state.
-
gr(float) –Growth-rate scale.
Returns:
-
rate(ndarray of shape (n_samples,)) –Growth rate for each sample.
simulate_ornstein_uhlenbeck(Om, D, m0, S0, nsamples, ndim, Dt, K, dt=0.006)
Simulate snapshots from a linear Ornstein-Uhlenbeck process.
Parameters:
-
Om(ndarray of shape (ndim, ndim)) –Drift matrix.
-
D(ndarray of shape (ndim, ndim)) –Diffusion matrix.
-
m0(ndarray of shape (ndim,)) –Mean of the initial Gaussian distribution.
-
S0(float) –Isotropic variance factor for the initial covariance
S0 * I. -
nsamples(int) –Number of particles sampled at each snapshot time.
-
ndim(int) –State dimension.
-
Dt(float) –Snapshot interval in simulation time.
-
K(int) –Number of snapshots.
-
dt(float, default:0.006) –Euler-Maruyama integration step.
Returns:
-
samples(list of length K) –samples[k]is an ndarray of shape(nsamples, ndim). -
tt(ndarray of shape (K,)) –Snapshot times.
simulate_toggle_switch(model_params, vol, gr, nsamples, ndim, Dt, K, dt=0.01)
Simulate snapshots from stochastic toggle-switch dynamics.
Parameters:
-
model_params(array-like of shape (7,)) –Toggle-switch parameters
[a1, a2, b1, b2, k1, k2, n]. -
vol(float) –System volume scaling the stochastic term.
-
gr(float) –Growth-rate scale. Growth is active only when
gr > 0. -
nsamples(int) –Number of particles sampled at the initial time.
-
ndim(int) –State dimension.
-
Dt(float) –Snapshot interval in simulation time.
-
K(int) –Number of snapshots.
-
dt(float, default:0.01) –Euler-Maruyama integration step.
Returns:
-
samples_full(list of length K) –samples_full[k]is an ndarray of shape(n_k, ndim), wheren_kcan increase across snapshots when growth is active. -
tt(ndarray of shape (K,)) –Snapshot times.
toggle_switch(x, model_params)
Evaluate the deterministic toggle-switch production term.
Parameters:
-
x(ndarray of shape (n_samples, 2)) –State values, where each row is
[x1, x2]. -
model_params(array-like of shape (7,)) –Model parameters
[a1, a2, b1, b2, k1, k2, n].
Returns:
-
f(ndarray of shape (n_samples, 2)) –Deterministic production term for each sample.