Introduction
New evidence should move your belief in a hypothesis by an amount that depends on how diagnostic that evidence actually is — not just on gut feel. ProbabilityOfHypothesisGivenData applies Bayes' Theorem to update a prior probability into a posterior given observed data (and the counterfactual posterior if the data hadn't been observed), and — when you supply payoff values for each combination of decision and outcome — also computes the Expected Value of Information (EVOI), answering the practical question of whether collecting the evidence is worth its cost in the first place.
Bayesian updating and EVOI are essential for:
- Clinical Diagnostics: Updating the probability of a disease given a test result (sensitivity/specificity).
- Intelligence Analysis: Assessing the likelihood of a threat based on new signal intelligence.
- Quality Engineering: Determining if additional destructive testing is cost-effective.
- Epidemiology: Estimating true infection prevalence from imperfect screening data.
- Cybersecurity: Refining the probability of a system compromise based on IDS alerts.
- Financial Risk: Evaluating the value of a market research report before purchase.
- Legal Analysis: Updating the probability of guilt/innocence given a new piece of forensic evidence.
- Environmental Science: Assessing the value of additional soil sampling for contamination mapping.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
prior_probability_of_hypothesis_being_truerequired | float | — | The initial belief (0 to 1) that the hypothesis is true before seeing the data. |
prior_probability_of_data_given_hypothesis_being_truerequired | float | — | The 'likelihood' or probability of observing the data if the hypothesis were true (e.g., test sensitivity). |
prior_probability_of_data_given_hypothesis_being_falserequired | float | — | The probability of observing the data if the hypothesis were false (e.g., false positive rate). |
return_results | bool | False | Whether to return the calculated values as a dictionary. If False, the function only prints the results. Defaults to False. |
payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true | float | None | The value or utility gained if you correctly bet the hypothesis is true. |
payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false | float | None | The value or utility (often 0 or a penalty) if you bet true but the hypothesis is false. |
payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true | float | None | The value or utility if you bet false but the hypothesis is actually true. |
payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false | float | None | The value or utility gained if you correctly bet the hypothesis is false. |
Returns
If return_results is True, a dictionary containing posterior probabilities and, if payoffs were provided, expected values and the Expected Value of Information. Otherwise returns None and prints results to the console.
Example
from analysistoolbox.probability import ProbabilityOfHypothesisGivenData
# Healthcare: revising the probability of a rare disease after a positive test result
# Disease prevalence (prior): 1%, Test Sensitivity: 95%, False Positive Rate: 5%
results = ProbabilityOfHypothesisGivenData(
prior_probability_of_hypothesis_being_true=0.01,
prior_probability_of_data_given_hypothesis_being_true=0.95,
prior_probability_of_data_given_hypothesis_being_false=0.05,
return_results=True
)