Bayes's theorem

Let's start considering the following example:

Example

A screw factory has two machines, the M1, which is old, and does 75% of all the screws, and the M2, newer but small, that does 25% of the screws. The M1 does 4% of defective screws, while the M2 just does 2% of defective screws. If we choose a screw at random: what is the probability that ir turns out to be defectively?

As we have seen, we could solve the problem using the theorem of the total probability. Remember that it was the same as to use a tree to solve it.

Let's look now at the problem from another point of view. If we know that a screw is defective: what is the probability that it has been made by machine M1?

In other words, we are wondering for the conditional probability P(M1/D). On the one hand, for the definition of conditional probability, we have that:

P(M1/D)=P(M1D)P(D)

On the other hand, if we represent our problem in a tree, we see that we can compute P(M1D), since it is the probability of the colored branch: to be made by M1 and to be defective.

imagen

Remember that the theorem of total probability is: P(D)=P(M1)P(D/M1)+P(M2)P(D/M2) So we obtain: P(M1/D)=P(M1)P(D/M1)P(M1)P(D/M1)+P(M2)P(D/M2)

In our example, P(M1/D)=0,750,040,750,04+0,250,02=0,857

What we have done to solve this problem can be generalized through the Bayes' theorem.

  • Bayes' Theorem:

    Let A1,A2,,An be a partition of the sample space and B uan event associated with the same experiment. Then, we have that: P(Ai/B)=P(Ai)P(B/Ai)P(A1)P(B/A1)++P(An)P(B/An)

Let's see how to apply it.

Example

We have three boxes with light bulbs. The first one contains 10 bulbs, with 4 of them broken; in the second one there are 6 light bulbs, and only one broken, and in the third one there are three broken light bulbs out of eight. Now we want to ask ours: If we take a broken bulb what is the probability that comes from box 1?

Let's remember that C1, C2, C3 represent boxes 1, 2 and 3. Also F= "broken bulb", for what F= "not broken bulb".

Now, we are only interested in the top branch of our tree.

imagen

We are interested in P(C1/F). From Bayes' theorem, P(C1/F)=P(C1)P(F/C1)P(C1)P(F/C1)+P(C2)P(F/C2)+P(C3)P(F/C3)

In our case, P(C1/F)=1341013410+1316+1338=430113360=48113=0,425

that is to say, 42,5%.

Example

Suppose we have 250 doctors from Europe meeting in a conference. Among these 115 are Germans; 65, French, and 70 Englishmen. We also know that, 75% of the Germans, 60% of the French and 65% of the Englishmen are in favour of using a new vaccine for the flu. In order to decide whether the vaccine is finally used they agree on the following: among all the doctors they select at random three doctors, who answer if they are in favour or not (with replacement). Remember that with replacement means that a doctor can be selected all three times (or two times). The vaccine is approved out of these three picks, at least two agree on using the vaccine. We are now interested in: If we pick a doctor randomly and he is in favor of using the vaccine: what is the probability that he is French?

Let's consider the following events: A= "German doctor", F= "French doctor", I= "English doctor", and V= "to be in favor of the vaccine" (and therefore, V= "o be against the vaccine").

We represent our problem in a tree.

imagen

We are looking for P(F/V). From Bayes' theorem, P(F/V)=P(F)P(V/F)P(A)P(V/A)+P(F)P(V/F)+P(I)P(V/I)

In our case, P(F/V)=652500,61152500,75+652500,6+702500,65=0,228