Welcome to a lesson on Bayes Theorem. Bayes theorem, also known as Bayes rule,
or Bayes' law
is given here for the probability of A given B.
But before we apply Bayes theorem, let's look at an example of conditional
probability,
and solve it intuitively and then see if we get the same results using Bayes theorem.
A certain virus infects one in every four hundred people.
A test used to detect the virus in a person is positive
eighty-five percent of the time if the person has the virus,
and five percent of the time if the person does not have the virus.
This five percent is called the false positives,
because they test positive but don't have the virus.
We'll that A be the event, the person has the virus,
and B be the event, the person tests positive for the virus.
A: We want to find the probability that a person has the virus given
that they have tested positive, meaning the probability of A given B.
B: We want to find the probability that a person does not have the virus
given that they tested negative, meaning the probability
of not A, given not B.
Let's organize the information in a table.
Looking at this first column,
if A, in the event they have the virus,
then not A, would be when they don't have the virus.
And if B is when they test positive, not B
would mean a test negative. To help us complete this table,
let's look at an example where we consider
ten thousand people as a sample.
If the virus infects one in every four hundred people,
the probability of A is equal to one divided by four hundred, or
point zero, zero, two, five. So to determine how many of these ten thousand people
would actually have the virus, we'll find the product of ten thousand
and point zero, zero, two five. So ten thousand
times
point zero, zero, two, five tells us that,
of the ten thousand people, twenty-five
would be infected with the virus. Which means this row here,
must have a total of twenty-five. And then ten thousand minus twenty-five,
or nine thousand nine hundred seventy-five would be the number of
people that don't have the virus.
Next, a person is positive
eighty-five percent of the time if the person has the virus.
So of these twenty-five people, eighty-five percent of them
would test positive. So we can say the probability
of B, given A is equal to eighty-five percent,
or point eight, five. Again this is the probability.
The person tests positive, given
they have the virus. So let's find eighty-five percent of twenty-five,
which would go in this cell here. Twenty-five
times point eight, five. I know we can't have a fraction of a person
but for our theoretical probability, let's go ahead and put in twenty-one point two, five
for the number of people that have the virus and test positive.
Which means a difference of twenty-five minus and twenty-one point two, five
would be the number people that have the virus and test negative.
Twenty-five minus twenty-one point, two, five is three point seven, five.
Next, five percent of those that test positive
don't have the virus.
Which means a probability
of B, given not A equals five percent or point, zero, five.
Again this is the probability of testing positive,
given they don't have the virus. So five percent of these people here,
will test positive even though they don't have the virus.
So let's find five percent of nine thousand, nine hundred seventy-five.
This comes out to four hundred ninety-eight point seven, five,
which would be in this cell here.
So the difference between
nine thousand, nine hundred seventy five and this value, would be the number of people
that don't have the virus and test negative.
So nine thousand, nine hundred seventy-five minus
four hundred ninety-eight point seven, five is equal to
nine thousand, four hundred seventy-six point two, five.
If we find the sum of this column here, we get five hundred twenty,
this is the number of people that
test positive for the virus. The total of this column here
is nine thousand, four hundred eighty. This is the number of people that would test
negative. Notice how this row and this column both total
ten thousand, which is a number of people we're considering.
Now from this table we should be able to find the conditional probabilities
that we we're asked to find. To find the probability of A given B,
for the probability of having the virus given they test positive,
well five hundred twenty people out of the ten thousand,
test positive, and twenty-one point two, five
actually have the virus. So twenty-one point two, five
divided by five hundred twenty, will give us the probability of A given B.
We'll calculate this in just a moment, but let's first find
the probability not A, given not B.
Well, total number of people that tested negative
is nine thousand, four hundred eighty. Of those,
nine thousand, four hundred seventy-six point two, five
would be not A, meaning don't have the virus.
So the probability of not A, given not B, would be equal to this quotient.
To save some time I've already found these values,
which are here. So the probability of A
given B, would be approximately point zero, four, zero, nine,
or approximately four point zero, nine percent. This value should be quite surprising.
This means only four point zero, nine percent
of the people that test positive actually have the virus.
Which means hopefully there's a better test to determine who's infected with the virus.
The probability of not A given not B,
meaning the probability a person doesn't have a disease,
given they tested negative, is approximately nine point nine, six percent,
which actually is good. So this test is pretty good for determining who doesn't
have the disease,
and it's not very good for determining who does have the disease.
Now let's go back to Bayes theorem and verify this first conditional probability.
Again here's Bayes theorem from an earlier slide.
And from our problem the given information was the probability of A is equal
to point zero, zero, two, five.
The probability not A is equal to point nine, nine,
seven, five. The probability of B given A was twenty-five.
And the probability of B given not A
was point zero, five. So if we take these values
and sub them into Bayes theorem, which we see here.
If we simplify this, we do get the same result that we found from our table
where probability of A given B is approximately
point zero, four, zero nine, or four point zero, nine percent.
But I think a lot of times,
it'll be easier to use our intuition to find these conditional probabilities,
rather than memorize Bayes theorem.
Now I hope you found this explanation helpful.