baysian formula python

Solutions on MaxInterview for baysian formula python by the best coders in the world

showing results for - "baysian formula python"
Anton
18 Sep 2018
1def prob_drunk_given_positive(prob_drunk_prior, false_positive_rate, true_positive_rate):
2  # true positive rate P(+|User)
3  p_pos_infected= true_positive_rate
4
5  # prior Probability P(User)
6  p_infected= prob_drunk_prior #Enter the probaility of the last test
7
8  # false positive rate P(+|Non-user)
9  p_post_not_infected= false_positive_rate
10
11  # P(Non-user)
12  p_not_infected = 1-p_infected
13
14  p_pos_infected,p_infected,p_post_not_infected,p_not_infected
15
16  p_infected_pos = (p_pos_infected*p_infected)/((p_pos_infected*p_infected)+(p_post_not_infected*p_not_infected))
17  
18  return p_infected_pos
19
20
21
22
23prob_drunk_prior = 1/100
24false_positive_rate = 0.08
25true_positive_rate = 1
26
27result = []
28
29while prob_drunk_prior < 0.95 :
30  currentProb= prob_drunk_given_positive(prob_drunk_prior, false_positive_rate, true_positive_rate)
31  prob_drunk_prior = currentProb
32  print(prob_drunk_prior)
33  result.append(prob_drunk_prior)