oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Bayes' Theorem #419

Open oldoc63 opened 2 years ago

oldoc63 commented 2 years ago

We have introduced conditional probability as a part of the multiplication rule for dependent events. However, let's go a bit more in-depth with it as it is a powerful probability tool that has real-world applications.

We see the following:

Now suppose that we test a bunch of people for strep throat. The possible results of these test are:

Image

If someone gets a positive result, what is the probability that they have a strep throat?

$$ P(ST|+) $$

oldoc63 commented 2 years ago

Imagine that you are a patient who has recently tested positive for strep throat. You may want to know the probability that you HAVE strep throat, given that you tested positive:

$$ P(ST|+) $$

To calculate this probability, we will use something called Bayes Theorem:

$$ P(B|A) = \frac{P(A|B).P(B)}{P(A)} $$

$$ P(ST|+) = \frac{P(+|ST).P(ST)}{P(+)} $$

We already know:

$$ P(+|ST) = 0.85 $$

$$ P(ST) = 0.20 $$

To calculate P(+):

$$ P(+) = P(ST and +) + (PNO ST and +) $$

$$ P(+) = 0.17 + 0.016 $$

$$ P(+) = 0.186 $$

$$ P(ST|+) = \frac{0.85 * 0.20}{0.186} = 0.914 $$

There is a 91.4% chance that you actually have strep throat given you test positive. This is not obvious from the information outlined in our tree diagram, but with Bayes Theorem, we were able to calculated it!

oldoc63 commented 2 years ago

Find:

$$ P(ST|-) $$

$$ P(ST|-) = \frac{P(-|ST).P(ST)}{P(-)} $$

$$ P(ST|-) = \frac{0.15 * 0.20}{0.814} = 0.037 $$

oldoc63 commented 2 years ago

Find:

$$ P(NO ST|+) $$

$$ P(NOST|+) = \frac{P(+|NOST) * P(NOST)}{P(+)} $$

$$ P(NOST|+) = \frac{0.02 * 0.80}{0.186} = 0.086 $$

Alternatively:

Since the only two events given a patient is positive are ST or NO ST, we can say:

$$ P(NOST|+) + P(ST|+) = 1 $$

$$ P(NO ST|+) = 1 - P(ST|+) $$

$$ P(NO ST|+) = 0.086 $$