tyche.probability

This module contains probability calculations that are used in many places in Tyche.

exception tyche.probability.TycheProbabilityException(message)[source]

An exception type that is thrown when errors occur in the use of the probability methods in this module.

Parameters:

message (str) –

tyche.probability.random_probability(rng, shape=None)[source]

Returns a random probability from the range [0, 1].

Parameters:
  • rng (Generator) –

  • shape (Optional[Union[int, tuple]]) –

tyche.probability.uncertain_bayes_rule(prob_concept, prob_obs, prob_obs_given_concept, likelihood)[source]

Bayes’ rule for uncertain observations.

Let A be a concept, and B be an observation with a phi=likelihood chance of being true. P(A|B) = phi * P(B|A) * P(A) / P(B) + (1 - phi) * (1 - P(B|A)) * P(A) / (1 - P(B))

To avoid division by zero, the following special cases are also used: - If likelihood is 0, then P(A|B) = (1 - likelihood) * (1 - P(B|A)) * P(A) / (1 - P(B)) - If likelihood is 1, then P(A|B) = likelihood * P(B|A) * P(A) / P(B)

The rules for this were derived by applying bayes rule to the event that the observation occurred or was incorrectly observed ((event with likelihood) OR (NOT event with 1 - likelihood)). Therefore, a likelihood of 0 represents that the observation was observed to be false (this is equivalent to observing NOT observation). See: https://stats.stackexchange.com/questions/345200/applying-bayess-theorem-when-evidence-is-uncertain

Parameters:
  • prob_concept (float) –

  • prob_obs (float) –

  • prob_obs_given_concept (float) –

  • likelihood (float) –