why and where bayes is used code example
Example: baysian formula python
def prob_drunk_given_positive(prob_drunk_prior, false_positive_rate, true_positive_rate):
p_pos_infected= true_positive_rate
p_infected= prob_drunk_prior
p_post_not_infected= false_positive_rate
p_not_infected = 1-p_infected
p_pos_infected,p_infected,p_post_not_infected,p_not_infected
p_infected_pos = (p_pos_infected*p_infected)/((p_pos_infected*p_infected)+(p_post_not_infected*p_not_infected))
return p_infected_pos
prob_drunk_prior = 1/100
false_positive_rate = 0.08
true_positive_rate = 1
result = []
while prob_drunk_prior < 0.95 :
currentProb= prob_drunk_given_positive(prob_drunk_prior, false_positive_rate, true_positive_rate)
prob_drunk_prior = currentProb
print(prob_drunk_prior)
result.append(prob_drunk_prior)