Now that we understand the addition rule and the multiplication rule, and we started to talk about
conditional probability, we want to talk about Bayes Theorem, which is a really important concept
in probability.
And just walking through the theorem itself is a little confusing, but when we use an example, it's
actually not too tough.
So the theorem itself says the probability of event a happening given that event B has already occurred,
is equal to the probability of B given A multiplied by the probability of a divided by the probability
of B.
And remember, with all these probability formulas, we can let event A and event B be anything we want
to.
We're just using A and B as placeholders.
So as an example so that we can understand what this theorem is actually doing, let's say that we have
two factories or assembly lines, so we have assembly line one and assembly line two.
And let's say that 3% of the parts produced on line one are defective, while 1% of the parts produced
on line two are defective.
In other words, we've been studying these assembly lines over a long period of time.
We've taken lots of samples and we already know that the defective rate for line one is 3%.
The defective rate for line two is 1%.
That's kind of historical information that we have.
OC So we have defective rates for each of these lines.
What Bayes Theorem allows us to do is answer a question like this one.
So given that we got a defective part, what is the probability that it came from line one or we could
say came from line two?
In other words, we're getting defective parts from line one, we're getting defective parts from line
two, but we're getting them at different rates.
Now.
We have a defective part in our hand, and we want to know the probability that it came from one line
or the other.
It's almost like calculating the probability of something in the past or going back in time.
I have a defective part at this point.
I don't know which assembly line it came from.
I want to know the likelihood that it came from line one versus line two.
What's the probability that the defective part came from one assembly line versus the other?
So to use Bayes Theorem to answer a question like this one, the first thing we always need to do is
identify event A and event B, right?
Our Bayes Theorem formula is given to us in terms of events A and B, we need to now assign those things
real names so that we don't get confused.
So this is saying, given a defective part, what is the probability that it came from line one?
And Bayes theorem allows us to calculate the probability of A given B, So if we match up that language
to the question that we're trying to answer, the probability of event A given event B given that event
B has already occurred.
Well, in our question, we're saying given that we have a defective part, so we're going to say that
event B.
Is the event that we get a defective part.
So given that we pull a defective part.
What is the probability that it came from line one?
What is the probability of a a must be coming from?
Line one.
So we're saying event A is the part coming from line one.
Event B is the part being defective.
Now we need to calculate these three probabilities on the right hand side of the theorem.
So let's start with the probability of event A So the probability of event A is the probability of the
part coming from line one.
Well, let's just say that there's an equal likelihood that we choose apart from line one or line two.
So we'll say that this probability is one half.
Now, this could change, for instance, if line one produces 90% of all of the parts and line two produces
only 10% of all of the parts, then the probability that the part comes from line one would be 90% or
nine over ten.
But if we say that 50% of all the parts come from line one and 50% come from line two, then there's
an equivalent chance of choosing line one or line two, which means the probability of event a choosing
line one is one out of two, one and two one half 50%.
Now the probability of event B, given that A has already happened is simple as well.
In fact, we've already been given it in the information in the question.
This probability is the probability of a defective part event.
B Given that the part comes from line one event.
A Well, we already know that that probability is 3% or three over 100, because if the part is coming
from line one, we know that line one has a 3% defective rate.
So the probability of the part is defective, given that it comes from line one is three over 100.
So these things are easy to calculate.
The toughest probability to figure out is the probability of event B, the probability that the part
is defective, because we have to consider both line one and line two.
Let's first think about the probability that the part comes from line one and is also defective.
Well, remember our multiplication rule.
If we say the probability that the part comes from line one and is defective, or we could write this
as line one.
And.
Defective is equal to.
This is our multiplication rule.
We have to multiply the probability that the part comes from line one, which we know is.
One half by the probability that the part is defective, which we know is three over 100.
So three over 100 or three over 200.
Now the probability that the part comes from.
Line two and is.
Defective again is our multiplication rule for independent events.
We get the probability that the part comes from line two multiplied by the probability that it's defective.
For line two, that's one over 100.
So we're going to get one over 200, which means then that the probability.
Of a defective part.
We get using the addition rule.
It's the probability that the part came from line one and was defective or came from line two and was
defective because either of those scenarios would result in a defective part.
And so we have to then add these two probabilities together.
So three over 200 plus one over 200 is for over 200 or.
One over 50.
So the probability that the part is defective is one over 50.
Now, with all three of these values, we can actually calculate the probability we're looking for using
Bayes Theorem.
So let's actually write this all out.
We'll say the probability that the part came from line one, given that it was.
Defective is equal to the probability that it was defective, given that it came from line one three
over 100 multiplied by the probability of event A, the probability that it came from line one.
One half.
All divided by probability of event B, the probability that it was defective, which in this case is
one over 50.
And when we do that math, we get in the numerator here three times one is three, 100 times two is
200.
So we get three over 200 divided by one over 50.
When we divide by a fraction, that's the same as multiplying by the reciprocal.
So we say three over 200.
And then instead of dividing by one over 50, we multiply by 50 over one.
We flip that fraction upside down and we get 150 over 200, which simplifies to three over four or.
75%.
So there's a three in four chance or a 75% chance that the part came from assembly line number one,
given that the part was defective.
So if we're holding a defective part in our hand and we don't know whether it came from line one or
came from line two, we know that the probability tells us that there's a 75% chance, there's a three
out of four chance that the defective part came from line one compared to line two.
And of course, given what we know about complimentary probability, if there's a 75% chance, the defective
part came from line one, that means by definition that there's a 25% chance that the defective part
came from line two.
Now there is another tool we can use to answer questions using Bayes Theorem, and it's this idea of
a tree diagram.
And this is something that helps a lot of people because this formula itself can be confusing.
It takes some practice.
Sometimes it helps to see a visual.
So the idea here with this same question is that we have an equally likely chance of choosing line one
or line two, because these assembly lines each produce 50% of all of our parts.
So we have a 50% chance of choosing line one and a 50% chance of choosing line two.
We could also write this as one half and one half.
And so we build out this first decision in our tree diagram.
And then from here off of assembly line one, we can get defective parts or we can get what we call
compliant parts or non defective parts.
Well, we know that line one produces defective parts at a 3% rate.
So we could say that this is 3% or three in 100, which means compliant parts are produced at a 97%
rate or 97 in 100.
And then off of assembly line two, we can get defective parts.
Line two produces defective parts at a 1% rate.
So we can say 1% here or one in 100, which means that line two produces compliant parts at a 99% rate
or 99 in 100.
Now, going back to our same question, given that we have a defective part, what is the probability
that it came from line one?
Once we've built out this tree diagram, this decision tree, what we want to do is sort of trim off
all the branches or ignore all of the paths in the tree that don't lead to the question we're trying
to answer.
In other words, we're looking at defective parts only, not compliant parts.
So we can sort of ignore this whole part.
This whole part will cancel out that part of the tree, cancel out this part of the tree.
We're ignoring all of the compliant sides of our tree and just looking at the defective sides.
So what we can say then is that the probability that we chose, apart from line one, given that the
part was defective.
So we'll say the probability of choosing a part from line one, it's going to be equal to.
We look then at the number of branches that lead to defective from line one, this number right here.
So three and we divide that by the total number of branches that lead to defective anywhere in our tree,
which is this value three, but also this value of one.
We have one branch leading to defective here, three branches leading to defective here.
And so we say three plus one or three over four, which is that same three out of four number.
We calculated earlier that same 75% figure as the chance that our part came from line one.
Given that it was defective, we could obviously use this same tree diagram to see the probability that
the part came from line two, given that it was defective.
So we could say the probability that it came from line two is equal to we would take this value one,
divide it by the total possibilities, three and one, so three and one, and we would get one over
four or 25%, which of course we already know to be the case because 100% -75% gives us that 25%.
These are complementary probabilities.
So that's the fundamental idea behind Bayes Theorem, given that I'm holding a defective part in my
hand and I know that assembly line number one produces defective parts, and assembly line number two
produces defective parts.
What's the probability what's the likelihood that the defective part I'm holding was built on assembly
line number one or was built on assembly line number two?
It's kind of a way for us to look back in time to figure out the likelihood that some event occurred
in the past, given the fact that we know that the part we have is defective.