Sunday, May 21, 2006

Statistics - Bayes' Therom

If we have a soap company with two plants, let’s say Ohio and Virginia. Ohio makes 60% of the soap; Virginia makes 40% of it. All the soap is mixed together at a third facility for shipping. If we had a bad bar of soap the chance that it would be bad and from Ohio is 60%. But that assumes both plants have the same rate of defective soaps. This changes when we learn that 5% oh the soap made in Ohio is defective, and 10% of the soap made in Virginia is food. Should this change our 60% and 40% ratio? Yes it should. Bayes' theorem says:



P(E1 | B) = P(E1) P(B | E1) / P(E1) P(B | E1) + P(E2) P(B | E2)



Where En equals the n possible numbers of an event. B is the event that will affect P (En). The fraction can go to include all events. How does this affect our soap? Well the formula as typed here holds.



P (Ohio | D) = P (Ohio) P (D | Ohio) / P (D)



And


P (Virginia | D) = P (Virginia) P (D | Virginia) / P (D)



P (D) = P (Ohio) P (D | Ohio) + P(Virginia) P(D | Virginia)



From our case: P (D | Ohio) = 0.05 and P (D | Virginia) = 0.10

As well as P (Ohio) = 0.60 and P (Virginia) = 0.40



P (Ohio | D) = P (0.60) P (0.05) / P (D)



P (Virginia | D) = P (0.40) P (0.10) / P (D)



P (D) = P (0.60) P (0.05) + P (0.40) P (0.10)



Let’s solve for P (D)

.6 * .05 = 0.03

.4 * .1 = 0.04



So

P (D) = 0.03 + 0.04 = 0.07



Finish it off:




P (Ohio | D) = P (0.03) / P (0.07)



P (Virginia | D) = P (0.04) / P (0.07)



P (Ohio | D) = .4286

P (Virginia | D) = .5714




These revised estimates are called posterior probabilities.


The book suggest a table format to make things easier to follow







EventPrior Prob.Conditional ProbJoint Prob. Revised Prob
Ohio.6.05.6 * .05 = >03.03/.07 = .4286
Virginia.4.1.4 * .1 = .04.4/.7 = .52174
Totals .071.0

No comments:

Post a Comment