Answers for "favorite superhero bayes theorem python"

1

baysian formula python

def prob_drunk_given_positive(prob_drunk_prior, false_positive_rate, true_positive_rate):
  # true positive rate P(+|User)
  p_pos_infected= true_positive_rate

  # prior Probability P(User)
  p_infected= prob_drunk_prior #Enter the probaility of the last test

  # false positive rate P(+|Non-user)
  p_post_not_infected= false_positive_rate

  # P(Non-user)
  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)
Posted by: Guest on September-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language