run_markov_chain_AB module¶
- itrails.run_markov_chain_AB.compute_matrices_end_wrapper(prob_mats, exponential_time, omega_end_masks, num_combinations)[source]¶
Parallel wrapper that computes the sliced matrix result for each combination by invoking compute_matrix_end on each set of inputs; for every index from 0 to num_combinations-1, it multiplies the corresponding probability matrix (from prob_mats) with the result of slicing the exponential_time matrix using the corresponding omega_end_mask, and aggregates all results into a single numpy array; the computations are performed in parallel using joblib.Parallel with ncpu.N_CPU_GLOBAL workers.
- Parameters:
prob_mats (list or np.ndarray.) – List or array of probability matrices where each element is a numpy array.
exponential_time (np.ndarray.) – Numpy array representing the matrix computed by applying the exponential function to the transition matrix multiplied by time.
omega_end_masks (list or np.ndarray of bool.) – List or array of boolean vectors used to mask the columns of the exponential_time matrix for each combination.
num_combinations (int.) – Total number of combinations (iterations) over which to compute the sliced matrix.
- Returns:
Numpy array containing the resulting matrices computed for each combination.
- Return type:
np.ndarray.
- itrails.run_markov_chain_AB.compute_matrices_start_end_wrapper(prob_mats, exponential_time, omega_start_masks, omega_end_masks, num_combinations)[source]¶
Parallel wrapper that computes the sliced matrix result for each combination by invoking compute_matrix_start_end on each set of inputs; for every index from 0 to num_combinations-1, it multiplies the corresponding probability matrix (from prob_mats) with the result of slicing the exponential_time matrix using the corresponding omega_start_mask and omega_end_mask, and aggregates all results into a single numpy array; the computations are performed in parallel using joblib.Parallel with ncpu.N_CPU_GLOBAL workers.
- Parameters:
prob_mats (list or np.ndarray.) – List or array of probability matrices where each element is a numpy array.
exponential_time (np.ndarray.) – Numpy array representing the matrix computed by applying the exponential function to the transition matrix multiplied by time.
omega_start_masks (list or np.ndarray of bool.) – List or array of boolean vectors used to mask the rows of the exponential_time matrix for each combination.
omega_end_masks (list or np.ndarray of bool.) – List or array of boolean vectors used to mask the columns of the exponential_time matrix for each combination.
num_combinations (int.) – Total number of combinations (iterations) over which to compute the sliced matrix.
- Returns:
Numpy array containing the resulting matrices computed for each combination.
- Return type:
np.ndarray.
- itrails.run_markov_chain_AB.compute_matrix_end(prob_mat, exponential_time, omega_end_mask)[source]¶
Helper function that computes the first matrix multiplication, then slices the matrix to get the columns corresponding to the end state.
- Parameters:
prob_mat (Numpy array) – Matrix of probabilities
exponential_time (Numpy array) – Exponential matrix of transition matrix multiplied by time.
omega_end_mask (Numpy array of booleans.) – Vector of booleans that masks the columns of the matrix.
- Returns:
Sliced matrix
- Return type:
Numpy array
- itrails.run_markov_chain_AB.compute_matrix_start_end(prob_mat, exponential_time, omega_start_mask, omega_end_mask)[source]¶
Helper function that computes all matrix multiplications but the first, then slices the matrix to get the rows corresponding to the starting state and columns corresponding to the end state.
- Parameters:
prob_mat (Numpy array) – Matrix of probabilities
exponential_time (Numpy array) – Exponential matrix of transition matrix multiplied by time.
omega_start_mask (Numpy array of booleans.) – Vector of booleans that masks the rows of the matrix.
omega_end_mask (Numpy array of booleans.) – Vector of booleans that masks the columns of the matrix.
- Returns:
Sliced matrix
- Return type:
Numpy array
- itrails.run_markov_chain_AB.run_markov_chain_AB(trans_mat, times, omega_dict, prob_dict, n_int_AB)[source]¶
Function that runs the Discrete Time Markov chain for species A and B.
- Parameters:
trans_mat (Numpy array) – Transition matrix.
times (Numpy array) – Array of cut times.
omega_dict (Numba typed dictionary) – Dictionary of omega indices (key) and vector of booleans where each key has the states (value).
prob_dict (Numba typed dictionary) – Dictionary of each path (keys) and probabilities for each state at the start of the first time interval (values).
n_int_AB (int) – Number of intervals for species A and B.
- Returns:
Updated dictionary of each path (keys) and probabilities for each state at the end of the last time interval (values).
- Return type:
Numba typed dictionary