Module 3 - Interpretation of probability and Bayes
theorem: Interpreting probability, Bayes’ Theorem and
independence and inferences from bayes theorem.
Ume Ayesha
BCA 4 SEM
1 What is Probability?
Probability is a way to measure how likely it is that an event will happen. It is always a
number between 0 (impossible) and 1 (certain). But what does that number actually mean?
There are two main ways to think about it:
1.1 1. The Frequentist View (The ”Long Run” View)
This view says that probability is based on repeating an experiment many times.
• Example: When we say the probability of a coin landing on Heads is 0.5 (or 50%),
a frequentist means: ”If you flip this coin thousands of times, about 50% of the flips
will be Heads.”
• Key Idea: Probability is a fixed, objective fact about the world that we discover
through repetition.
1.2 2. The Bayesian View (The ”Belief” View)
This view says that probability is a measure of your personal confidence or belief that
something is true, based on the information you currently have.
• Example: ”There is an 80% chance it will rain tomorrow.” You can’t repeat tomorrow
thousands of times to find out. Instead, 80% represents the meteorologist’s confidence
based on current weather data.
• Key Idea: Probability can change as you get new information. If you look out the
window and see dark clouds, your belief (probability) that it will rain goes up!
1
2 Independent Events
Two events are independent if knowing that one happened gives you absolutely no clues
about whether the other will happen.
• Example: Flipping a coin and rolling a die. Getting a ”Heads” does not change the
chances of rolling a ”4”.
The Math Rule: If event A and event B are independent, the chance of both happening
is just their probabilities multiplied together:
P (A and B) = P (A) × P (B)
3 Bayes’ Theorem: The Formula for Learning
Bayes’ Theorem is a famous mathematical formula that tells us exactly how to update our
beliefs when we get new evidence.
3.1 The Formula
P (B | A) × P (A)
P (A | B) =
P (B)
What the symbols mean:
• P (A): Prior Belief. How confident were you in A before you saw the new evidence?
• P (B | A): Likelihood. If A is true, how likely were you to see this exact evidence B?
• P (B): Evidence. How common is this evidence B overall?
• P (A | B): Updated Belief (Posterior). How confident are you in A now that you
have seen the evidence B?
4 Inference: Using Bayes’ Theorem in Real Life
”Bayesian Inference” is just a fancy term for using Bayes’ theorem to solve real-world prob-
lems. Let’s look at a simple example to see how our brains sometimes trick us, and how
Bayes’ theorem fixes it.
4.1 The Spam Filter Example
Imagine you are building an email spam filter.
• Prior: Most emails are good. Only 20% of all emails you get are spam. So, P (Spam) =
0.20.
2
• Evidence: You get an email containing the word ”Lottery”.
• Likelihood: You know that 80% of spam emails use the word ”Lottery”. But, 5% of
normal emails also use it (maybe your friends talking about winning).
If you see an email with the word ”Lottery”, your brain might panic and say ”80% of
spam uses that word, it must be spam!”
But Bayes’ theorem forces us to remember the Prior (that most emails are good). When
you actually plug the numbers into Bayes’ theorem, it balances the fact that the word
”Lottery” is suspicious against the fact that spam is relatively rare to begin with. It gives
you the exact, logical probability that the email is spam, preventing you from overreacting
to a single clue.
Practice Questions
1. A company has 65% male and 35% female employees. 80% of male employees have
attended a leadership training program, while 60% of female employees have attended
it. If a randomly selected employee has attended the program, use the concept of
Bayes’ theorem to calculate what is the probability that the employee is male?
2. At a university, 55% of students are in the Science stream, while 45% are in the Arts
stream. Among Science students, 75% enroll in a Data Science elective, while 40%
of Arts students take the course. If a randomly chosen student is found to be taking
Data Science, use the concept of Bayes’ theorem to calculate the probability that they
belong to the Science stream?
3. In a hospital, 70% of patients are adults and 30% are children. A certain disease affects
40% of adults and 20% of children. If a randomly selected patient is diagnosed with
the disease, use the concept of Bayes’ theorem to calculate the probability that they
are an adult?
4. A music festival attracts 55% local residents and 45% tourists. 60% of local residents
purchase VIP tickets, whereas only 30% of tourists do. If a randomly selected VIP
ticket holder is chosen, use the concept of Bayes’ theorem to calculate the probability
that they are a local resident?
5. A clothing store finds that 50% of its customers are men and 50% are women. 65% of
men prefer online shopping, while 40% of women do. If a randomly chosen customer
prefers online shopping, use the concept of Bayes’ theorem to calculate the probability
that the customer is male?
6. A mobile gaming app has 75% free users and 25% premium users. 20% of free users
make in-app purchases, whereas 70% of premium users do. If a randomly selected
user is found to have made an in-app purchase, use the concept of Bayes’ theorem to
calculate the probability that they are a premium user?
3
Solutions
1. Company Training Problem
Let M be the event the employee is male, and F be female. Let T be the event the
employee attended training.
Given: P (M ) = 0.65, P (F ) = 0.35
P (T |M ) = 0.80, P (T |F ) = 0.60
To find P (M |T ):
P (T |M )P (M )
P (M |T ) =
P (T |M )P (M ) + P (T |F )P (F )
(0.80)(0.65)
P (M |T ) =
(0.80)(0.65) + (0.60)(0.35)
0.52 0.52 52
P (M |T ) = = = ≈ 0.7123
0.52 + 0.21 0.73 73
Answer: The probability the employee is male is approximately 71.23%.
2. University Stream Problem
Let S be Science stream, A be Arts stream, and D be taking Data Science.
Given: P (S) = 0.55, P (A) = 0.45
P (D|S) = 0.75, P (D|A) = 0.40
To find P (S|D):
P (D|S)P (S)
P (S|D) =
P (D|S)P (S) + P (D|A)P (A)
(0.75)(0.55)
P (S|D) =
(0.75)(0.55) + (0.40)(0.45)
0.4125 0.4125 165 55
P (S|D) = = = = ≈ 0.6962
0.4125 + 0.1800 0.5925 237 79
Answer: The probability the student is in the Science stream is approximately 69.62%.
3. Hospital Disease Problem
Let A be Adult, C be Child, and D be diagnosed with the disease.
Given: P (A) = 0.70, P (C) = 0.30
P (D|A) = 0.40, P (D|C) = 0.20
To find P (A|D):
P (D|A)P (A)
P (A|D) =
P (D|A)P (A) + P (D|C)P (C)
(0.40)(0.70)
P (A|D) =
(0.40)(0.70) + (0.20)(0.30)
0.28 0.28 14
P (A|D) = = = ≈ 0.8235
0.28 + 0.06 0.34 17
4
Answer: The probability the patient is an adult is approximately 82.35%.
4. Music Festival VIP Problem
Let L be Local resident, T be Tourist, and V be purchasing a VIP ticket.
Given: P (L) = 0.55, P (T ) = 0.45
P (V |L) = 0.60, P (V |T ) = 0.30
To find P (L|V ):
P (V |L)P (L)
P (L|V ) =
P (V |L)P (L) + P (V |T )P (T )
(0.60)(0.55)
P (L|V ) =
(0.60)(0.55) + (0.30)(0.45)
0.33 0.33 330 22
P (L|V ) = = = = ≈ 0.7097
0.33 + 0.135 0.465 465 31
Answer: The probability the VIP ticket holder is a local resident is approximately
70.97%.
5. Clothing Store Problem
Let M be Man, W be Woman, and O be prefers online shopping.
Given: P (M ) = 0.50, P (W ) = 0.50
P (O|M ) = 0.65, P (O|W ) = 0.40
To find P (M |O):
P (O|M )P (M )
P (M |O) =
P (O|M )P (M ) + P (O|W )P (W )
(0.65)(0.50)
P (M |O) =
(0.65)(0.50) + (0.40)(0.50)
0.325 0.325 325 13
P (M |O) = = = = ≈ 0.6190
0.325 + 0.200 0.525 525 21
Answer: The probability the customer is male is approximately 61.90%.
6. Gaming App Purchases Problem
Let F be Free user, P be Premium user, and I be making an in-app purchase.
Given: P (F ) = 0.75, P (P ) = 0.25
P (I|F ) = 0.20, P (I|P ) = 0.70
To find P (P |I): (Note: We are finding the probability they are a Premium user)
P (I|P )P (P )
P (P |I) =
P (I|P )P (P ) + P (I|F )P (F )
(0.70)(0.25)
P (P |I) =
(0.70)(0.25) + (0.20)(0.75)
5
0.175 0.175 175 7
P (P |I) = = = = ≈ 0.5385
0.175 + 0.150 0.325 325 13
Answer: The probability the user is a premium user is approximately 53.85%.
7. In a factory which manufactures bolts, machines A, B and C manufacture 30%, 40%
and 30% of the bolts respectively. Of their output 2%, 3%, and 5% respectively are
defective bolts. A bolt is drawn at random from the product and is found to be
defective. Illustrate the probability that this is manufactured by:
(a) Machine A
(b) Machine B
(c) Machine C
8. A factory produces three types of gadgets: Type X, Type Y, and Type Z. The produc-
tion probabilities for these gadgets are as follows: Type X: 40%, Type Y: 35%, Type
Z: 25%. Each gadget has a probability of being defective: Type X: 5%, Type Y: 4%,
Type Z: 3%. If a randomly selected gadget from the production line is found to be
defective, illustrate the probability of that gadget being from:
(a) Type X
(b) Type Y
(c) Type Z
9. Illustrate what is Bayes’ theorem and answer the following question: In a population,
2% of people are infected with a virus. A test used to detect the virus has a 98%
sensitivity (the probability of a positive test given that the person is infected) and a
97% specificity (the probability of a negative test given that the person is not infected).
If a person tests positive, employ Bayes’ theorem to find what is the probability that
they are actually infected with the virus.
10. (a) Illustrate the following terms: experiment, sample space, event, and favorable
outcome.
(b) Illustrate the following terms: conditional probability and Bayes’ theorem.
11. Illustrate what is Bayes’ theorem and answer the following question: A weather fore-
caster predicts a 70% chance of rain. Historical data shows that when the forecaster
predicts rain, it actually rains 80% of the time. On days when the forecaster predicts
no rain, it still rains 10% of the time. Given that it rained today, use Bayes’ theorem
to illustrate what is the probability that the forecaster had predicted rain.
12. Illustrate what is Bayes’ theorem and answer the following question: Three candidates,
A, B, and C, have applied for a job in a private company. The chances of their selection
are in the ratio 1:2:4. If selected, the probabilities that A, B, and C will introduce
changes to improve the company’s profits are 0.8, 0.5, and 0.3, respectively. If no
improvement occurs in the company, solve to illustrate the probability that it is due
to the appointment of candidate C.
6
Solutions
7. Factory Bolts Problem
Let A, B, C be the events that the bolt is manufactured by Machine A, B, and C
respectively. Let D be the event the bolt is defective.
Given:
P (A) = 0.30, P (B) = 0.40, P (C) = 0.30
P (D|A) = 0.02, P (D|B) = 0.03, P (D|C) = 0.05
Total Probability of a Defective Bolt, P (D):
P (D) = P (D|A)P (A) + P (D|B)P (B) + P (D|C)P (C)
P (D) = (0.02)(0.30) + (0.03)(0.40) + (0.05)(0.30) = 0.006 + 0.012 + 0.015 = 0.033
(a) Probability it is from Machine A, P (A|D):
P (D|A)P (A) 0.006 6 2
P (A|D) = = = = ≈ 0.1818
P (D) 0.033 33 11
(b) Probability it is from Machine B, P (B|D):
P (D|B)P (B) 0.012 12 4
P (B|D) = = = = ≈ 0.3636
P (D) 0.033 33 11
(c) Probability it is from Machine C, P (C|D):
P (D|C)P (C) 0.015 15 5
P (C|D) = = = = ≈ 0.4545
P (D) 0.033 33 11
8. Gadget Factory Problem
Let X, Y, Z be the events of selecting gadgets of Type X, Y, and Z. Let D be the event
of a defective gadget.
Given:
P (X) = 0.40, P (Y ) = 0.35, P (Z) = 0.25
P (D|X) = 0.05, P (D|Y ) = 0.04, P (D|Z) = 0.03
Total Probability P (D):
P (D) = (0.05)(0.40) + (0.04)(0.35) + (0.03)(0.25) = 0.020 + 0.014 + 0.0075 = 0.0415
(a) Probability it is Type X, P (X|D):
0.020 200 40
P (X|D) = = = ≈ 0.4819
0.0415 415 83
(b) Probability it is Type Y, P (Y |D):
0.014 140 28
P (Y |D) = = = ≈ 0.3373
0.0415 415 83
7
(c) Probability it is Type Z, P (Z|D):
0.0075 75 15
P (Z|D) = = = ≈ 0.1807
0.0415 415 83
9. Bayes’ Theorem and Virus Testing
Bayes’ Theorem: A mathematical formula used to determine conditional probabili-
ties. It allows us to update the probability of a hypothesis (like having a virus) based
on new evidence (like a positive test result). Mathematically: P (A|B) = P (B|A)P
P (B)
(A)
.
Problem Solution:
Let V be the event of having the virus, and P be a positive test.
Given:
P (V ) = 0.02 =⇒ P (¬V ) = 0.98
Sensitivity P (P |V ) = 0.98
Specificity P (¬P |¬V ) = 0.97 =⇒ P (P |¬V ) = 1 − 0.97 = 0.03 (False Positive rate)
To find P (V |P ):
P (P |V )P (V )
P (V |P ) =
P (P |V )P (V ) + P (P |¬V )P (¬V )
(0.98)(0.02) 0.0196 0.0196
P (V |P ) = = = = 0.40
(0.98)(0.02) + (0.03)(0.98) 0.0196 + 0.0294 0.0490
The probability the person is actually infected is 40%.
10. Definitions
(a) • Experiment: A procedure that can be infinitely repeated and has a well-
defined set of possible outcomes (e.g., rolling a die).
• Sample Space: The set of all possible outcomes of an experiment, usually
denoted by S.
• Event: A subset of the sample space. It is a specific collection of outcomes
(e.g., rolling an even number).
• Favorable Outcome: The specific outcome(s) that satisfy the condition of
the event you are looking for.
(b) • Conditional Probability: The probability of an event occurring given that
another event has already occurred. Denoted as P (A|B).
• Bayes’ Theorem: A theorem describing how to update the probability of
a hypothesis based on new evidence. It relates the conditional and marginal
probabilities of two random events.
8
11. Weather Forecaster Problem
Bayes’ Theorem Definition: (Refer to Q9 definition).
Let P R be the event the forecaster Predicts Rain, and P N be Predicts No Rain. Let
R be the event it actually Rains.
Given:
P (P R) = 0.70 =⇒ P (P N ) = 0.30
P (R|P R) = 0.80, P (R|P N ) = 0.10
To find P (P R|R):
P (R|P R)P (P R)
P (P R|R) =
P (R|P R)P (P R) + P (R|P N )P (P N )
(0.80)(0.70)
P (P R|R) =
(0.80)(0.70) + (0.10)(0.30)
0.56 0.56 56
P (P R|R) = = = ≈ 0.9492
0.56 + 0.03 0.59 59
The probability the forecaster had predicted rain is approximately 94.92%.
12. Job Candidates Problem
Bayes’ Theorem Definition: (Refer to Q9 definition).
Let A, B, C be the events of selecting candidate A, B, or C. Let I be the event of
improvement, so ¬I is no improvement.
Given Prior Probabilities (Ratio 1:2:4):
P (A) = 1/7, P (B) = 2/7, P (C) = 4/7
Given conditional probabilities of improvement:
P (I|A) = 0.8 =⇒ P (¬I|A) = 0.2
P (I|B) = 0.5 =⇒ P (¬I|B) = 0.5
P (I|C) = 0.3 =⇒ P (¬I|C) = 0.7
To find P (C|¬I):
P (¬I|C)P (C)
P (C|¬I) =
P (¬I|A)P (A) + P (¬I|B)P (B) + P (¬I|C)P (C)
Calculate the numerator:
4 2.8
P (¬I|C)P (C) = 0.7 × =
7 7
Calculate the denominator (Total probability of no improvement):
1 2 4 0.2 + 1.0 + 2.8 4.0
P (¬I) = 0.2 × + 0.5 × + 0.7 × = =
7 7 7 7 7
Substitute back into Bayes’ formula:
2.8
7 2.8 28 7
P (C|¬I) = 4.0 = = = = 0.70
7
4.0 40 10
The probability that the lack of improvement is due to candidate C is 70%.