Bayes' Theorem - Formula, Use and Examples

Hey there! Welcome to KnowledgeKnot! Don't forget to share this with your friends and revisit often. Your support motivates us to create more content in the future. Thanks for being awesome!
Prerequisites: Basic Probability, Conditional Probability

Bayes' Theorem

It is a way to figure out the probability of something happening based on prior knowledge or information. It helps us to update our beliefs or predictions when we receive new evidence. In simpler words, it's like adjusting our guess about something as we learn more about it.

Formula for Bayes' Theorem

The formula for Bayes' theorem can be written as:
P(AB)=P(BA)×P(A)P(B)P(A|B) = \frac{P(B|A) \times P(A)}{P(B)}

Where:
- P(AB)P(A|B) is the probability of event A happening given that event B has occurred. This is called the posterior probability.
- P(BA)P(B|A) is the probability of event B happening given that event A has occurred. This is called the likelihood.
- P(A)P(A) is the prior probability of event A happening.
- P(B)P(B) is the prior probability of event B happening.
This formula allows you to update your belief about the probability of event A happening based on new evidence B.

Example Use of Bayes' Theorem

An insurance company has insured 1000 truck drivers, 3000 car drivers and 6000 scooter drivers. The probabilities that the truck, car and scooter drivers meet with an accident are 0.20.2, 0.040.04 and 0.250.25, respectively. One of the insured persons meets with an accident. What is the probability that the person is a car driver?

Answer:

To find the probability that the person involved in the accident is a car driver, we can use Bayes' theorem.
Let AA represent the event that the person involved in the accident is a car driver.
Let BB represent the event that the person involved in the accident is any type of driver (truck, car, or scooter).
We want to find P(AB)P(A | B), the probability that the person involved in the accident is a car driver given that they are any type of driver.
According to Bayes' theorem:
P(AB)=P(BA)×P(A)P(B)P(A | B) = \frac{P(B | A) \times P(A)}{P(B)}
Given:
- P(A)P(A) = Probability that the person involved in the accident is a car driver = 300010000\frac{3000}{10000}
- P(BA)P(B | A) = Probability that the person involved in the accident is any type of driver given that they are a car driver = 0.040.04 (as provided in the question)
- P(B)P(B) = Probability that the person involved in the accident is any type of driver
Now, let's calculate P(B)P(B):
P(B)=1000×0.2+3000×0.04+6000×0.2510000P(B) = \frac{1000 \times 0.2 + 3000 \times 0.04 + 6000 \times 0.25}{10000}
P(B)=200+120+150010000P(B) = \frac{200 + 120 + 1500}{10000}
P(B)=182010000P(B) = \frac{1820}{10000}
P(B)=0.182P(B) = 0.182
Now, substitute the values into Bayes' theorem:
P(AB)=0.04×3000100000.182P(A | B) = \frac{0.04 \times \frac{3000}{10000}}{0.182}
P(AB)=0.04×0.30.182P(A | B) = \frac{0.04 \times 0.3}{0.182}
P(AB)=0.0120.182P(A | B) = \frac{0.012}{0.182}
P(AB)0.0120.1820.0659P(A | B) ≈ \frac{0.012}{0.182} ≈ 0.0659
Therefore, the probability that the person involved in the accident is a car driver is approximately 0.06590.0659 or 6.59%6.59\%.

Example Use of Bayes' Theorem

A factory has three machines (A, B, and C) that produce widgets. Machine A produces 50% of the widgets, Machine B produces 30%, and Machine C produces 20%. The defect rates for these machines are 2%, 3%, and 5%, respectively. If a widget is selected at random and found to be defective, what is the probability that it was produced by Machine A?

Answer:

To find the probability that the defective widget was produced by Machine A, we can use Bayes' theorem.
Let AA represent the event that the defective widget was produced by Machine A.
Let BB represent the event that a widget is defective.
We want to find P(AB)P(A | B), the probability that the defective widget was produced by Machine A given that it is defective.
According to Bayes' theorem:
P(AB)=P(BA)P(A)P(B)P(A | B) = \frac{P(B | A) \cdot P(A)}{P(B)}
Given:
- P(A)P(A) = Probability that a widget is produced by Machine A = 0.50.5
- P(BA)P(B | A) = Probability that a widget is defective given that it is produced by Machine A = 0.020.02
- P(B)P(B) = Probability that a widget is defective
Now, let's calculate P(B)P(B):
P(B)=(0.5×0.02)+(0.3×0.03)+(0.2×0.05)P(B) = (0.5 \times 0.02) + (0.3 \times 0.03) + (0.2 \times 0.05)
P(B)=0.01+0.009+0.01P(B) = 0.01 + 0.009 + 0.01
P(B)=0.029P(B) = 0.029
Now, substitute the values into Bayes' theorem:
P(AB)=0.02×0.50.029P(A | B) = \frac{0.02 \times 0.5}{0.029}
P(AB)=0.010.029P(A | B) = \frac{0.01}{0.029}
P(AB)0.3448P(A | B) ≈ 0.3448
Therefore, the probability that the defective widget was produced by Machine A is approximately 0.34480.3448 or 34.48%34.48\%.

Example Use of Bayes' Theorem

A medical test is used to detect a certain disease. The test has a sensitivity (true positive rate) of 99% and a specificity (true negative rate) of 98%. The prevalence of the disease in the population is 0.5%. If a person tests positive, what is the probability that they actually have the disease?

Answer:

To find the probability that a person who tested positive actually has the disease, we can use Bayes' theorem.
Let AA represent the event that a person has the disease.
Let BB represent the event that a person tests positive.
We want to find P(AB)P(A | B), the probability that a person has the disease given that they test positive.
According to Bayes' theorem:
P(AB)=P(BA)P(A)P(B)P(A | B) = \frac{P(B | A) \cdot P(A)}{P(B)}
Given:
- P(A)P(A) = Probability that a person has the disease (prevalence) = 0.0050.005
- P(BA)P(B | A) = Probability that a person tests positive given that they have the disease (sensitivity) = 0.990.99
- P(B)P(B) = Probability that a person tests positive
Now, let's calculate P(B)P(B):
P(B)=(P(BA)×P(A))+(P(B¬A)×P(¬A))P(B) = (P(B | A) \times P(A)) + (P(B | \neg A) \times P(\neg A))
P(B)=(0.99×0.005)+(0.02×0.995)P(B) = (0.99 \times 0.005) + (0.02 \times 0.995)
P(B)=0.00495+0.0199P(B) = 0.00495 + 0.0199
P(B)=0.02485P(B) = 0.02485
Now, substitute the values into Bayes' theorem:
P(AB)=0.99×0.0050.02485P(A | B) = \frac{0.99 \times 0.005}{0.02485}
P(AB)0.1996P(A | B) ≈ 0.1996
Therefore, the probability that a person who tested positive actually has the disease is approximately 0.19960.1996 or 19.96%19.96\%.