Bayes Theorem
- When the prior is unknown, a popular strategy is to take a best guess and analyze how output varies as a function of discrepancies in that guess.
import numpy as np
import matplotlib.pyplot as plt
def bayes(pEgH, pEnH, pH):
"""
pEgH: p evidence given hypothesis (true positivity)
pEnH: p evidence not given hypothesis (false positivity)
pH: p hypothesis (prior)
"""
return (pEgH * pH) / (pEgH * pH + pEnH * (1-pH))
pEgH = 0.9
pEnH = 0.1
priors = np.arange(0, 0.1, 1e-4)
probabilities = list(map(lambda p: bayes(pEgH, pEnH, p), priors))
plt.plot(priors, probabilities)