Python small experimental mathematics (3) - Bayes 'rule (Bayes' rule) Case computing

Python small experimental mathematics (3) - Bayes 'rule (Bayes' rule) Case computing

1. Bayes 'rule (Bayes' rule)

P ( B A ) = P ( A / B ) P ( B ) j = 1 n P ( B i ) P ( A B i ) P(B|A)=\frac{P(A/B)P(B)}{\sum_{j=1}^nP(B_i)P(A|B_i)}

2. Case: drug detection Case

Suppose the probability of a conventional sensitivity and reliability of the detection results are 99%, i.e., when the drug is subject, each test positive (+) was 99%. While not subject drugs, each tested negative (-) 99% probability. Suppose 0.5% employee drug.

How high is the probability of an employee tested positive for drug use? Order "D" drug, "N" for drug, "+" is a positive
P ( D ) = 0.005 P ( N ) = 0.995 P ( + D ) = 0.99 P ( + N ) = 0.01 P(D)=0.005\\ P(N)=0.995\\ P(+|D)=0.99\\ P(+|N)=0.01\\
Available:

P ( + ) = P ( + , D ) + P ( + , N ) = P ( + D ) P ( D ) + P ( + N ) P ( N ) = 0.0149 P ( D + ) = P ( + D ) P ( D ) P ( + ) = 0.99 0.005 / 0.0149 = 0.332 P(+)=P(+,D)+P(+,N)=P(+|D)P(D)+P(+|N)P(N)=0.0149\\ P(D|+)=\frac{P(+|D)P(D)}{P(+)}=0.99*0.005/0.0149=0.332
Despite the high reliability of the detection results, but can only come to the following conclusion: If the test is positive, then this person is very likely probability drugs only 33% false positives.

3. understand the formula

Bayes' rule illustration

P ( A B = P ( B ) P ( A B ) = P ( A ) P ( B A ) P(A \cap B)= P(B)*P(A|B) =P(A)*P(B|A)
P ( A B ) P(A \cap B) can be understood as: under the condition B occurs, the probability of occurrence of A; or a conditional probability of occurrence of A, B occurs

Symbol Editor reference to the formula: https://www.jianshu.com/p/e74eb43960a1
(continue to add updated)

Guess you like

Origin blog.csdn.net/houhuipeng/article/details/90706539