# 统计学之-贝叶斯法则编程

#Return the probability of flipping one head each from two coins
#One coin has a probability of heads of p1 and the other of p2

def f(p1,p2):
return p1*(1-p2) + (1-p1)*p2

print f(0.5,0.8)

### 抛硬币

#Two coins have probabilities of heads of p1 andd p2
#The probability of selecting the first coin is p0
#Return the probability of a flip landing on heads

def f(p0,p1,p2):
return p0*p1 + (1-p0)*p2


### 癌症案例

#Calculate the probability of a positive result given that
#p0=P(C)
#p1=P(Positive|C)
#p2=P(Negative|Not C)

def f(p0,p1,p2):
print f(0.01, 0.9, 0.8)