Questions on Baye's Theorem

Bayes' Theorem

Definition, Formula and 10 University-Level Solved Problems

Definition of Bayes' Theorem

Bayes' theorem is used to calculate the probability of an event after new information or evidence has become available.

Let A and B be two events such that

P(B) > 0.

Then Bayes' theorem is

P(A | B) = [P(B | A) P(A)] / P(B)

Here:

  • P(A | B) = posterior probability
  • P(B | A) = likelihood
  • P(A) = prior probability
  • P(B) = probability of the evidence
Prior Likelihood Posterior P(A) P(B | A) P(A | B)
Figure 1: Bayes' theorem updates prior probability using new evidence.

General Form

If A1, A2, ..., An form a partition of the sample space, then

P(Ai | B) = [P(Ai) P(B | Ai)] / Σ P(Aj) P(B | Aj)
Example 1: Two Machines

A factory has two machines M1 and M2. Machine M1 produces 60% of the items and M2 produces 40%. Their defective rates are 2% and 5%, respectively. An item selected randomly is found to be defective. Find the probability that it was produced by M2.

Item M1 = 0.60 M2 = 0.40 Defective 0.02 Good 0.98 Defective 0.05 Good 0.95
Figure 2: Probability tree for the two machines.
Show Detailed Solution

Let D denote the event that an item is defective.

P(M₁)=0.60,   P(M₂)=0.40
P(D | M₁)=0.02
P(D | M₂)=0.05

First calculate the total probability of a defective item.

P(D) = P(M₁)P(D | M₁) + P(M₂)P(D | M₂)
= (0.60)(0.02) + (0.40)(0.05)
= 0.012+0.020 = 0.032

Now apply Bayes' theorem:

P(M₂ | D) = [P(M₂)P(D | M₂)] / P(D)
= (0.40)(0.05)/0.032
= 0.020/0.032 = 0.625
Answer: 0.625 = 62.5%
Example 2: Medical Diagnosis

A disease affects 1% of a population. A diagnostic test has 95% sensitivity and a 4% false-positive rate. If a person tests positive, find the probability that the person actually has the disease.

Show Detailed Solution

Let D denote disease and + denote a positive test.

P(D)=0.01
P(Dᶜ)=0.99
P(+ | D)=0.95
P(+ | Dᶜ)=0.04

The total probability of a positive test is

P(+) = P(+ | D)P(D) + P(+ | Dᶜ)P(Dᶜ)
= (0.95)(0.01) + (0.04)(0.99)
= 0.0095+0.0396 = 0.0491

Now apply Bayes' theorem.

P(D | +) = [P(+ | D)P(D)]/P(+)
= 0.0095/0.0491
≈ 0.1935
Answer: Approximately 19.35%
A test with high sensitivity does not necessarily imply that a positive result means a very high probability of disease. The prevalence of the disease also matters.
Example 3: Selection of an Urn

There are three urns:

U1: 2 red and 3 blue balls
U2: 4 red and 1 blue ball
U3: 3 red and 3 blue balls

An urn is selected randomly and one ball is drawn. If the ball is red, find the probability that it came from U2.

Show Detailed Solution

Since the urn is selected randomly,

P(U₁)=P(U₂)=P(U₃)=1/3

The conditional probabilities of drawing red are

P(R | U₁)=2/5
P(R | U₂)=4/5
P(R | U₃)=3/6=1/2

Using the total probability theorem,

P(R) = (1/3)(2/5) + (1/3)(4/5) + (1/3)(1/2)
= 17/30

By Bayes' theorem,

P(U₂ | R) = [(1/3)(4/5)]/(17/30)
= 8/17
Answer: 8/17 ≈ 0.4706
Example 4: University Examination

At a university, 55% of students are undergraduate and 45% are postgraduate. Among undergraduate students, 70% pass an examination, whereas 85% of postgraduate students pass. If a randomly selected student has passed, find the probability that the student is postgraduate.

Show Detailed Solution

Let U denote undergraduate, G postgraduate, and P passing.

P(U)=0.55
P(G)=0.45
P(P | U)=0.70
P(P | G)=0.85

The total probability of passing is

P(P) = (0.55)(0.70) + (0.45)(0.85)
= 0.385+0.3825 = 0.7675

Now,

P(G | P) = [(0.45)(0.85)]/0.7675
= 0.3825/0.7675
≈0.4984
Answer: Approximately 49.84%
Example 5: Three Production Plants

Plants A, B and C produce 30%, 45% and 25% of a company's total products. Their defective rates are 1%, 2% and 4%, respectively. A product is found to be defective. Find the probability that it came from plant C.

Show Detailed Solution
P(A)=0.30, P(B)=0.45, P(C)=0.25
P(D | A)=0.01
P(D | B)=0.02
P(D | C)=0.04

Total probability of defect:

P(D) = (0.30)(0.01) + (0.45)(0.02) + (0.25)(0.04)
= 0.003+0.009+0.010 = 0.022

By Bayes' theorem,

P(C | D) = [(0.25)(0.04)]/0.022
= 0.010/0.022 = 5/11
Answer: 5/11 ≈ 45.45%
Example 6: Spam Email Detection

Suppose 20% of incoming emails are spam. A particular word occurs in 70% of spam emails but only 10% of non-spam emails. If an email contains the word, find the probability that it is spam.

Show Detailed Solution

Let S denote spam and W denote occurrence of the word.

P(S)=0.20
P(Sᶜ)=0.80
P(W | S)=0.70
P(W | Sᶜ)=0.10

Total probability that the word appears:

P(W) = (0.70)(0.20) + (0.10)(0.80)
= 0.14+0.08 = 0.22

Therefore,

P(S | W) = 0.14/0.22 = 7/11
Answer: 7/11 ≈ 63.64%
Example 7: Insurance Risk

An insurance company classifies 30% of its drivers as high-risk and 70% as low-risk. The annual accident probabilities are 20% and 5%, respectively. If a driver has an accident, find the probability that the driver belongs to the high-risk group.

Show Detailed Solution
P(H)=0.30
P(L)=0.70
P(A | H)=0.20
P(A | L)=0.05

Total probability of accident:

P(A) = (0.30)(0.20) + (0.70)(0.05)
= 0.060+0.035 = 0.095

Then

P(H | A) = 0.060/0.095
= 12/19 ≈0.6316
Answer: Approximately 63.16%
Example 8: Selection of a Biased Coin

A box contains three coins. Coin C1 is fair, coin C2 shows heads with probability 0.75, and coin C3 shows heads with probability 0.90. A coin is selected randomly and tossed once. If the result is a head, find the probability that C3 was selected.

Show Detailed Solution
P(C₁)=P(C₂)=P(C₃)=1/3
P(H | C₁)=0.50
P(H | C₂)=0.75
P(H | C₃)=0.90

Total probability of obtaining a head:

P(H) = (1/3)(0.50+0.75+0.90)
= 2.15/3

Then

P(C₃ | H) = [(1/3)(0.90)]/(2.15/3)
= 0.90/2.15 ≈0.4186
Answer: Approximately 41.86%
Example 9: Reliability of Sensors

Type A sensors constitute 70% of a monitoring system and type B sensors constitute 30%. Type A gives a false alarm with probability 0.03, while type B gives a false alarm with probability 0.08. A false alarm occurs. Find the probability that it came from a type B sensor.

Show Detailed Solution
P(A)=0.70
P(B)=0.30
P(F | A)=0.03
P(F | B)=0.08

Total probability of false alarm:

P(F) = (0.70)(0.03) + (0.30)(0.08)
= 0.021+0.024 = 0.045

Using Bayes' theorem,

P(B | F) = 0.024/0.045
= 8/15 ≈0.5333
Answer: Approximately 53.33%
Example 10: Diagnostic Test with Sensitivity and Specificity

A disease affects 5% of a population. A test has 90% sensitivity and 95% specificity. A person receives a positive result. Find the probability that the person actually has the disease.

Show Detailed Solution

The sensitivity is

P(+ | D)=0.90

The specificity is

P(- | Dᶜ)=0.95

Therefore the false-positive probability is

P(+ | Dᶜ)=1-0.95=0.05

Also,

P(D)=0.05
P(Dᶜ)=0.95

Total probability of a positive result:

P(+) = (0.90)(0.05) + (0.05)(0.95)
= 0.045+0.0475 = 0.0925

Using Bayes' theorem,

P(D | +) = [(0.90)(0.05)]/0.0925
= 0.045/0.0925 ≈0.4865
Answer: Approximately 48.65%
Although the test has 90% sensitivity, this does not mean that a positive test gives a 90% probability of disease. The prior probability of disease and the false-positive rate must also be considered.

Important Bayes' Theorem Formulas

1. Conditional Probability

P(A | B) = P(A ∩ B) / P(B)

2. Bayes' Theorem

P(A | B) = [P(B | A)P(A)] / P(B)

3. Total Probability Theorem

P(B) = Σ P(B | Ai)P(Ai)

4. General Bayes' Formula

P(Ai | B) = [P(B | Ai)P(Ai] / Σ[P(B | Aj)P(Aj)]

5. Bayesian Interpretation

Posterior ∝ Likelihood × Prior
Bayes' Theorem — University Level Probability

Try each problem independently and then click Show Detailed Solution to verify your answer.

Comments

Popular posts from this blog

Table of content

Chapter 1 : Set Theory: An Introduction

Types of Matrix