1
00:00:00,120 --> 00:00:04,080
Now that we understand the addition rule and the multiplication rule, and we started to talk about

2
00:00:04,080 --> 00:00:09,690
conditional probability, we want to talk about Bayes Theorem, which is a really important concept

3
00:00:09,690 --> 00:00:11,010
in probability.

4
00:00:11,190 --> 00:00:17,130
And just walking through the theorem itself is a little confusing, but when we use an example, it's

5
00:00:17,130 --> 00:00:18,510
actually not too tough.

6
00:00:18,510 --> 00:00:25,740
So the theorem itself says the probability of event a happening given that event B has already occurred,

7
00:00:25,770 --> 00:00:32,490
is equal to the probability of B given A multiplied by the probability of a divided by the probability

8
00:00:32,490 --> 00:00:32,970
of B.

9
00:00:32,970 --> 00:00:40,260
And remember, with all these probability formulas, we can let event A and event B be anything we want

10
00:00:40,260 --> 00:00:40,470
to.

11
00:00:40,500 --> 00:00:43,200
We're just using A and B as placeholders.

12
00:00:43,200 --> 00:00:49,500
So as an example so that we can understand what this theorem is actually doing, let's say that we have

13
00:00:49,500 --> 00:00:56,910
two factories or assembly lines, so we have assembly line one and assembly line two.

14
00:00:56,910 --> 00:01:05,580
And let's say that 3% of the parts produced on line one are defective, while 1% of the parts produced

15
00:01:05,580 --> 00:01:07,410
on line two are defective.

16
00:01:07,410 --> 00:01:12,030
In other words, we've been studying these assembly lines over a long period of time.

17
00:01:12,030 --> 00:01:17,310
We've taken lots of samples and we already know that the defective rate for line one is 3%.

18
00:01:17,310 --> 00:01:19,890
The defective rate for line two is 1%.

19
00:01:19,890 --> 00:01:22,140
That's kind of historical information that we have.

20
00:01:22,140 --> 00:01:25,920
OC So we have defective rates for each of these lines.

21
00:01:25,920 --> 00:01:30,840
What Bayes Theorem allows us to do is answer a question like this one.

22
00:01:31,020 --> 00:01:37,620
So given that we got a defective part, what is the probability that it came from line one or we could

23
00:01:37,620 --> 00:01:39,320
say came from line two?

24
00:01:39,330 --> 00:01:44,130
In other words, we're getting defective parts from line one, we're getting defective parts from line

25
00:01:44,130 --> 00:01:46,260
two, but we're getting them at different rates.

26
00:01:46,260 --> 00:01:46,560
Now.

27
00:01:46,560 --> 00:01:53,040
We have a defective part in our hand, and we want to know the probability that it came from one line

28
00:01:53,040 --> 00:01:53,610
or the other.

29
00:01:53,610 --> 00:01:58,620
It's almost like calculating the probability of something in the past or going back in time.

30
00:01:58,620 --> 00:02:00,780
I have a defective part at this point.

31
00:02:00,780 --> 00:02:03,870
I don't know which assembly line it came from.

32
00:02:03,870 --> 00:02:08,039
I want to know the likelihood that it came from line one versus line two.

33
00:02:08,070 --> 00:02:13,350
What's the probability that the defective part came from one assembly line versus the other?

34
00:02:13,350 --> 00:02:19,320
So to use Bayes Theorem to answer a question like this one, the first thing we always need to do is

35
00:02:19,320 --> 00:02:22,740
identify event A and event B, right?

36
00:02:22,740 --> 00:02:29,310
Our Bayes Theorem formula is given to us in terms of events A and B, we need to now assign those things

37
00:02:29,310 --> 00:02:31,950
real names so that we don't get confused.

38
00:02:32,070 --> 00:02:37,740
So this is saying, given a defective part, what is the probability that it came from line one?

39
00:02:37,740 --> 00:02:44,910
And Bayes theorem allows us to calculate the probability of A given B, So if we match up that language

40
00:02:44,910 --> 00:02:51,270
to the question that we're trying to answer, the probability of event A given event B given that event

41
00:02:51,300 --> 00:02:52,440
B has already occurred.

42
00:02:52,440 --> 00:02:57,390
Well, in our question, we're saying given that we have a defective part, so we're going to say that

43
00:02:57,390 --> 00:02:58,500
event B.

44
00:02:59,500 --> 00:03:03,690
Is the event that we get a defective part.

45
00:03:03,700 --> 00:03:06,490
So given that we pull a defective part.

46
00:03:06,520 --> 00:03:09,160
What is the probability that it came from line one?

47
00:03:09,160 --> 00:03:14,470
What is the probability of a a must be coming from?

48
00:03:15,450 --> 00:03:16,650
Line one.

49
00:03:16,650 --> 00:03:20,370
So we're saying event A is the part coming from line one.

50
00:03:20,400 --> 00:03:23,150
Event B is the part being defective.

51
00:03:23,160 --> 00:03:27,600
Now we need to calculate these three probabilities on the right hand side of the theorem.

52
00:03:27,600 --> 00:03:35,370
So let's start with the probability of event A So the probability of event A is the probability of the

53
00:03:35,370 --> 00:03:36,900
part coming from line one.

54
00:03:37,050 --> 00:03:43,530
Well, let's just say that there's an equal likelihood that we choose apart from line one or line two.

55
00:03:43,560 --> 00:03:46,650
So we'll say that this probability is one half.

56
00:03:46,650 --> 00:03:54,990
Now, this could change, for instance, if line one produces 90% of all of the parts and line two produces

57
00:03:54,990 --> 00:04:01,950
only 10% of all of the parts, then the probability that the part comes from line one would be 90% or

58
00:04:01,950 --> 00:04:02,970
nine over ten.

59
00:04:03,060 --> 00:04:08,700
But if we say that 50% of all the parts come from line one and 50% come from line two, then there's

60
00:04:08,700 --> 00:04:14,490
an equivalent chance of choosing line one or line two, which means the probability of event a choosing

61
00:04:14,490 --> 00:04:18,480
line one is one out of two, one and two one half 50%.

62
00:04:18,510 --> 00:04:26,820
Now the probability of event B, given that A has already happened is simple as well.

63
00:04:26,820 --> 00:04:30,270
In fact, we've already been given it in the information in the question.

64
00:04:30,420 --> 00:04:34,860
This probability is the probability of a defective part event.

65
00:04:34,860 --> 00:04:39,060
B Given that the part comes from line one event.

66
00:04:39,060 --> 00:04:47,610
A Well, we already know that that probability is 3% or three over 100, because if the part is coming

67
00:04:47,610 --> 00:04:51,720
from line one, we know that line one has a 3% defective rate.

68
00:04:51,720 --> 00:04:57,300
So the probability of the part is defective, given that it comes from line one is three over 100.

69
00:04:57,300 --> 00:04:59,970
So these things are easy to calculate.

70
00:04:59,970 --> 00:05:05,880
The toughest probability to figure out is the probability of event B, the probability that the part

71
00:05:05,880 --> 00:05:10,350
is defective, because we have to consider both line one and line two.

72
00:05:10,380 --> 00:05:15,840
Let's first think about the probability that the part comes from line one and is also defective.

73
00:05:15,840 --> 00:05:18,420
Well, remember our multiplication rule.

74
00:05:18,420 --> 00:05:27,480
If we say the probability that the part comes from line one and is defective, or we could write this

75
00:05:27,480 --> 00:05:29,430
as line one.

76
00:05:30,320 --> 00:05:31,160
And.

77
00:05:31,840 --> 00:05:34,090
Defective is equal to.

78
00:05:34,120 --> 00:05:36,160
This is our multiplication rule.

79
00:05:36,190 --> 00:05:42,430
We have to multiply the probability that the part comes from line one, which we know is.

80
00:05:43,160 --> 00:05:49,880
One half by the probability that the part is defective, which we know is three over 100.

81
00:05:49,880 --> 00:05:56,470
So three over 100 or three over 200.

82
00:05:56,480 --> 00:06:00,170
Now the probability that the part comes from.

83
00:06:00,980 --> 00:06:03,440
Line two and is.

84
00:06:04,290 --> 00:06:08,940
Defective again is our multiplication rule for independent events.

85
00:06:08,940 --> 00:06:15,930
We get the probability that the part comes from line two multiplied by the probability that it's defective.

86
00:06:16,110 --> 00:06:18,570
For line two, that's one over 100.

87
00:06:18,570 --> 00:06:24,780
So we're going to get one over 200, which means then that the probability.

88
00:06:25,700 --> 00:06:27,410
Of a defective part.

89
00:06:27,410 --> 00:06:30,080
We get using the addition rule.

90
00:06:30,080 --> 00:06:36,320
It's the probability that the part came from line one and was defective or came from line two and was

91
00:06:36,320 --> 00:06:40,970
defective because either of those scenarios would result in a defective part.

92
00:06:40,970 --> 00:06:44,090
And so we have to then add these two probabilities together.

93
00:06:44,090 --> 00:06:52,190
So three over 200 plus one over 200 is for over 200 or.

94
00:06:52,770 --> 00:06:53,990
One over 50.

95
00:06:54,000 --> 00:06:57,930
So the probability that the part is defective is one over 50.

96
00:06:57,960 --> 00:07:04,290
Now, with all three of these values, we can actually calculate the probability we're looking for using

97
00:07:04,290 --> 00:07:05,100
Bayes Theorem.

98
00:07:05,130 --> 00:07:07,050
So let's actually write this all out.

99
00:07:07,050 --> 00:07:14,610
We'll say the probability that the part came from line one, given that it was.

100
00:07:15,580 --> 00:07:22,990
Defective is equal to the probability that it was defective, given that it came from line one three

101
00:07:22,990 --> 00:07:30,610
over 100 multiplied by the probability of event A, the probability that it came from line one.

102
00:07:31,360 --> 00:07:32,360
One half.

103
00:07:32,470 --> 00:07:39,190
All divided by probability of event B, the probability that it was defective, which in this case is

104
00:07:39,190 --> 00:07:40,800
one over 50.

105
00:07:40,810 --> 00:07:46,270
And when we do that math, we get in the numerator here three times one is three, 100 times two is

106
00:07:46,270 --> 00:07:46,900
200.

107
00:07:46,900 --> 00:07:53,470
So we get three over 200 divided by one over 50.

108
00:07:53,470 --> 00:07:58,000
When we divide by a fraction, that's the same as multiplying by the reciprocal.

109
00:07:58,000 --> 00:08:00,310
So we say three over 200.

110
00:08:00,430 --> 00:08:06,550
And then instead of dividing by one over 50, we multiply by 50 over one.

111
00:08:06,550 --> 00:08:17,470
We flip that fraction upside down and we get 150 over 200, which simplifies to three over four or.

112
00:08:18,530 --> 00:08:20,110
75%.

113
00:08:20,120 --> 00:08:28,510
So there's a three in four chance or a 75% chance that the part came from assembly line number one,

114
00:08:28,520 --> 00:08:30,700
given that the part was defective.

115
00:08:30,710 --> 00:08:36,500
So if we're holding a defective part in our hand and we don't know whether it came from line one or

116
00:08:36,500 --> 00:08:42,679
came from line two, we know that the probability tells us that there's a 75% chance, there's a three

117
00:08:42,679 --> 00:08:47,860
out of four chance that the defective part came from line one compared to line two.

118
00:08:47,870 --> 00:08:53,360
And of course, given what we know about complimentary probability, if there's a 75% chance, the defective

119
00:08:53,360 --> 00:08:58,910
part came from line one, that means by definition that there's a 25% chance that the defective part

120
00:08:58,910 --> 00:09:00,080
came from line two.

121
00:09:00,440 --> 00:09:06,500
Now there is another tool we can use to answer questions using Bayes Theorem, and it's this idea of

122
00:09:06,500 --> 00:09:07,490
a tree diagram.

123
00:09:07,490 --> 00:09:12,860
And this is something that helps a lot of people because this formula itself can be confusing.

124
00:09:12,860 --> 00:09:13,790
It takes some practice.

125
00:09:13,790 --> 00:09:16,520
Sometimes it helps to see a visual.

126
00:09:16,670 --> 00:09:23,360
So the idea here with this same question is that we have an equally likely chance of choosing line one

127
00:09:23,360 --> 00:09:30,380
or line two, because these assembly lines each produce 50% of all of our parts.

128
00:09:30,500 --> 00:09:37,520
So we have a 50% chance of choosing line one and a 50% chance of choosing line two.

129
00:09:37,550 --> 00:09:41,570
We could also write this as one half and one half.

130
00:09:41,570 --> 00:09:46,070
And so we build out this first decision in our tree diagram.

131
00:09:46,430 --> 00:09:52,190
And then from here off of assembly line one, we can get defective parts or we can get what we call

132
00:09:52,190 --> 00:09:54,860
compliant parts or non defective parts.

133
00:09:54,860 --> 00:10:00,650
Well, we know that line one produces defective parts at a 3% rate.

134
00:10:00,650 --> 00:10:10,670
So we could say that this is 3% or three in 100, which means compliant parts are produced at a 97%

135
00:10:10,670 --> 00:10:14,030
rate or 97 in 100.

136
00:10:14,360 --> 00:10:18,140
And then off of assembly line two, we can get defective parts.

137
00:10:18,140 --> 00:10:21,230
Line two produces defective parts at a 1% rate.

138
00:10:21,230 --> 00:10:30,470
So we can say 1% here or one in 100, which means that line two produces compliant parts at a 99% rate

139
00:10:30,470 --> 00:10:33,650
or 99 in 100.

140
00:10:33,680 --> 00:10:38,660
Now, going back to our same question, given that we have a defective part, what is the probability

141
00:10:38,660 --> 00:10:40,250
that it came from line one?

142
00:10:40,370 --> 00:10:46,910
Once we've built out this tree diagram, this decision tree, what we want to do is sort of trim off

143
00:10:46,910 --> 00:10:52,880
all the branches or ignore all of the paths in the tree that don't lead to the question we're trying

144
00:10:52,880 --> 00:10:53,570
to answer.

145
00:10:53,570 --> 00:10:58,490
In other words, we're looking at defective parts only, not compliant parts.

146
00:10:58,490 --> 00:11:00,980
So we can sort of ignore this whole part.

147
00:11:00,980 --> 00:11:05,360
This whole part will cancel out that part of the tree, cancel out this part of the tree.

148
00:11:05,360 --> 00:11:11,390
We're ignoring all of the compliant sides of our tree and just looking at the defective sides.

149
00:11:11,390 --> 00:11:18,050
So what we can say then is that the probability that we chose, apart from line one, given that the

150
00:11:18,050 --> 00:11:19,280
part was defective.

151
00:11:19,280 --> 00:11:26,060
So we'll say the probability of choosing a part from line one, it's going to be equal to.

152
00:11:26,090 --> 00:11:33,530
We look then at the number of branches that lead to defective from line one, this number right here.

153
00:11:33,530 --> 00:11:40,940
So three and we divide that by the total number of branches that lead to defective anywhere in our tree,

154
00:11:40,940 --> 00:11:46,130
which is this value three, but also this value of one.

155
00:11:46,250 --> 00:11:50,540
We have one branch leading to defective here, three branches leading to defective here.

156
00:11:50,540 --> 00:11:59,330
And so we say three plus one or three over four, which is that same three out of four number.

157
00:11:59,330 --> 00:12:05,810
We calculated earlier that same 75% figure as the chance that our part came from line one.

158
00:12:05,810 --> 00:12:11,510
Given that it was defective, we could obviously use this same tree diagram to see the probability that

159
00:12:11,510 --> 00:12:13,940
the part came from line two, given that it was defective.

160
00:12:13,940 --> 00:12:21,710
So we could say the probability that it came from line two is equal to we would take this value one,

161
00:12:21,770 --> 00:12:29,510
divide it by the total possibilities, three and one, so three and one, and we would get one over

162
00:12:29,510 --> 00:12:39,290
four or 25%, which of course we already know to be the case because 100% -75% gives us that 25%.

163
00:12:39,290 --> 00:12:41,840
These are complementary probabilities.

164
00:12:41,840 --> 00:12:48,170
So that's the fundamental idea behind Bayes Theorem, given that I'm holding a defective part in my

165
00:12:48,170 --> 00:12:53,660
hand and I know that assembly line number one produces defective parts, and assembly line number two

166
00:12:53,660 --> 00:12:55,190
produces defective parts.

167
00:12:55,190 --> 00:13:00,680
What's the probability what's the likelihood that the defective part I'm holding was built on assembly

168
00:13:00,680 --> 00:13:03,710
line number one or was built on assembly line number two?

169
00:13:03,710 --> 00:13:10,070
It's kind of a way for us to look back in time to figure out the likelihood that some event occurred

170
00:13:10,070 --> 00:13:15,350
in the past, given the fact that we know that the part we have is defective.

