The UtilityFunctions submodule#
This submodule implements UtilityFunctions.R from the original R implementation in Python.
It contains functions useful for preprocessing training data.
- mhn.full_state_space.UtilityFunctions.KL_div(p: ndarray, q: ndarray) float#
Computes the Kullback–Leibler divergence between two probability distributions.
- Parameters:
p (np.ndarray) – Probability distribution p.
q (np.ndarray) – Probability distribution q.
- Returns:
The KL-divergence of p and q.
- Return type:
float
- mhn.full_state_space.UtilityFunctions.data_to_pD(data: ndarray) ndarray#
Calculates the probability distribution for the different events from a given binary mutation matrix.
- Parameters:
data (np.ndarray) – A numpy array or matrix representing the mutation data.
- Returns:
The probability distribution of the different events.
- Return type:
np.ndarray
- mhn.full_state_space.UtilityFunctions.finite_sample(p_th: ndarray, k: int) ndarray#
Generates a random sample given a probability distribution and returns the probability distribution for the new sample.
- Parameters:
p_th (np.ndarray) – Probability distribution of events (the distribution of a true Theta).
k (int) – The number of samples to generate.
- Returns:
The probability distribution of events from the generated samples.
- Return type:
np.ndarray
- mhn.full_state_space.UtilityFunctions.state_to_int(x: ndarray) int#
Interprets a binary array as a binary number and returns the corresponding integer value.
- Parameters:
x (np.ndarray) – Binary array, typically representing a row of the mutation matrix in this context.
- Returns:
The integer value corresponding to the binary array.
- Return type:
int