twinfer.simulation.gillespie_simulations.run_simulation
- twinfer.simulation.gillespie_simulations.run_simulation(update_propensities, update_matrix, pop0, time_points, n_cells=1000, promoter_indices=None, pop0_mat=None)[source]
Simulates the dynamics of a population of cells using the Gillespie algorithm.
- Parameters:
update_propensities (callable): A function to compute the propensities for reactions. update_matrix (numpy.ndarray): The stoichiometry matrix defining the system’s reactions. pop0 (numpy.ndarray): Initial population vector for all species (shape: [n_species]). time_points (numpy.ndarray): Array of time points at which to sample the population. n_cells (int, optional): Number of cells to simulate. Defaults to 1000.
- Returns:
- numpy.ndarray: A 3D array containing the simulated population data.
Shape: [n_species, len(time_points), n_cells].
- Notes:
The function uses a JIT-compiled helper function gillespie_simulation_all_cells for efficient simulation.
- Warnings are printed for cells that encounter issues during simulation:
Cell stuck due to zero propensities for too long.