bioin.motif.normalize_probability¶
-
bioin.motif.normalize_probability(probabilities)[source]¶ Rescale a collection of probabilityes so that they sum up to 1.
Parameters: probabilities (dict) – a dictionary of Probabilities, where keys are k-mers and values are the probabilities of these k-mers (which do no necessarily sum up to 1). Returns: Dictionary, a normalized dictionary where the probability of each k-mer was divided by the sun of all k-mers’ probabilities. Examples
To rescale a collection of probabilities (the sides of the die) so that these probabilities sum to 1, we will write a function called Normalize(Probabilities). This function takes a dictionary Probabilities whose keys are k-mers and whose values are the probabilities of these k-mers (which do not necessarily sum to 1). The function should divide each value in Probabilities by the sum of all values in Probabilities, then return the resulting dictionary.
>>> probabilities = {'A': 0.1, 'C': 0.1, 'G': 0.1, 'T': 0.1} >>> normalized_pro = normalize_probability(probabilities) >>> normalized_pro {'A': 0.25, 'C': 0.25, 'G': 0.25, 'T': 0.25}