1
Lahore Garrison University
MSDS-111 Statistical and Mathematical
Methods
for Data Science
Week-4 Semester-
Spring-2024
Prepared by:
Dr.Quratulain Rana
Assistant Professor
2
Learning Objectives
After studying this lecture, the students will be able to:
• Understand the concept of conditional probability.
• Learn how to use the formula for conditional probability.
• Learn how to find the probability of an event by using a partition of the sample space.
• Learn how to apply Bayes' Theorem to find the conditional probability of an event when the "reverse" conditional
probability is the probability that is known.
Dr. Quratulain Rana
3
Conditional Probability of an Event
Conditional probability of event A given event B is the probability that A occurs when B is known to
occur.
Some useful facts(conditional probability)
Dr. Quratulain Rana
4
Conditional Probability of an Event
Example:1
Ninety percent of flights depart on time. Eighty percent of flights arrive on time. Seventy-five percent of
flights depart on time and arrive on time.
(a) Eric is meeting Alyssa’s flight, which departed on time. What is the probability that Alyssa will arrive
on time?
(b) Eric has met Alyssa, and she arrived on time. What is the probability that her flight departed on time?
(c) Are the events, departing on time and arriving on time, independent?
Dr. Quratulain Rana
5
Conditional Probability of an Event
Example:1
Dr. Quratulain Rana
6
Conditional Probability of an Event
Example:2
There are two car factories, A and B. Each year, factory A produces 1000 cars, of which 10 are lemons.
Factory B produces 2 cars, each of which is a lemon. All cars go to a single lot, where they are
thoroughly mixed up. I buy a car.
•What is the probability it is a lemon?
•What is the probability it came from factory B?
• The car is revealed to be lemon. What is the probability it came from factory B.
Dr. Quratulain Rana
7
Conditional Probability of an Event
Example:2
Dr. Quratulain Rana
8
Joint Probability Tables
(useful for conditional probabilities)
The joint probability table for two events gives you probabilities for the events, their complements,
and combinations using and. Here is the joint probability table for two events
Dr. Quratulain Rana
9
Example:3
Your firm has classified orders as either large or small in dollar amount and as either light
or heavy in shipping weight. In the recent past, 28% of orders have been large dollar
amounts, 13% of orders have been heavy, and 10% of orders have been large in dollar
amounts and heavy in weight.
a) Construct the joint probability table for this situation.
b) Find the probability that an order is large in dollar amount or heavy.
c) Find the probability that an order is for a large dollar amount and is not heavy.
d) Of the orders with large dollar amounts, what percentage are heavy? What
conditional probability does this represent?
e) Of the heavy orders, what percentage are for large dollar amounts? What conditional
probability does this represent?
f) Are the events “large dollar amount” and “heavy” mutually exclusive? How do you
know?
g) Are the events “large dollar amount” and “heavy”
independent? How do you know?
Dr. Quratulain Rana
10
Introduction to Bayes Theorem
Bayes' theorem is a fundamental concept in probability and statistics that describes the probability of
an event, based on prior knowledge of the conditions that might be related to that event. It provides a
powerful framework for updating beliefs and making data-driven decisions.
Dr. Quratulain Rana
11
Bayes Theorem Application
Dr. Quratulain Rana
12
Fundamentals of Bayes Theorem
• Bayes' theorem is a fundamental concept in probability theory and statistical inference.
• It provides a way to calculate the conditional probability of an event, given prior knowledge or
evidence.
• The theorem relates the prior probability, likelihood, and posterior probability of an event or
hypothesis.
Dr. Quratulain Rana
13
Prior, Posterior, and Likelihood in Bayes
Theorem
Prior probability Posterior probability Likelihood
The prior probability The posterior probability is The likelihood is the
represents our initial the updated belief about an probability of observing
belief or expectation event after incorporating the given data or
about an event before new information or evidence evidence, assuming a
considering any new using Bayes' Theorem specific hypothesis or
evidence or data. model is true.
Dr. Quratulain Rana
14
Bayes Theorem
Example:1
You have a blood test for a rare disease that occurs by chance in 1 person in 100,000. If you have
the disease, the test will report that you do with probability 0.95 (and that you do not with
probability 0.05). If you do not have the disease, the test will report a false positive with
probability 1e-3. If the test says you do have the disease, what is the probability it that you actually
have the disease?
Dr. Quratulain Rana
15
Bayes Theorem
Example:2
A disease occurs with probability 0.4 (i.e. it is present in 40% of the population). You have a test that
detects the disease with probability 0.6, and produces a false positive with probability 0.1. What is the
posterior probability you have the disease if the test comes back positive?
Dr. Quratulain Rana
16
Bayes Theorem(Example:3)
In a certain assembly plant, three machines, B1, B2, and B3, make 30%, 45%, and 25%, respectively, of the
products. It is known from past experience that 2%, 3%, and 2% of the products made by each machine,
respectively, are defective. Now, suppose that a finished product is randomly selected.
(a) What is the probability that it is defective?
(b) If the product was chosen randomly and found to be defective, what is the probability that it was made by
machine B3?
Solution: Consider the following events:
A: the product is defective,
B1: the product is made by machine B1, So, P(B1)=0.30 , P(A/B1)=0.02(defective is from B1)
B2: the product is made by machine B2, P(B2)=0.45 , P(A/B2)=0.03(defective is from B2)
B3: the product is made by machine B3, & P(B3)=0.25 , P(A/B3)=0.02(defective is from B3)
Dr. Quratulain Rana
17
Solution
(a)
As we know that probability of defective can be calculated by using following formula:
P(A)=P(A and B1)+P(A and B2)+P(A and B3)
=P(A/B1).P(B1)+P(A/B2).P(B2)+P(A/B3).P(B3)
Hint: P(A/B1)=P(A and B1)/P(B1)
=(0.02)(0.30)+(0.03)(0.45)+(0.02)(0.25)
P(A and B1)=P(A/B1).P(B1)
=0.006+0.0135+0.005
=(0.02)(0.30)
=0.0245 Ans.
Dr. Quratulain Rana
18
Solution
(b)
Dr. Quratulain Rana
19
Bayes Theorem(Example:4)
Dr. Quratulain Rana
20
Solution:
Dr. Quratulain Rana
21
Home Assignment
Question:1
Among employees of a certain firm, 70% know Java, 60% know Python, and
50% know both languages. What portion of programmers
(a) does not know Python?
(b) does not know Python and does not know Java?
(c) knows Java but not Python? (d) knows Python but not Java?
(e) If someone knows Python, what is the probability that he/she knows Java too?
(f) If someone knows Java, what is the probability that he/she knows Python too?
Dr. Quratulain Rana
22
Home Assignment
Question:2
At a plant, 20% of all the produced parts are subject to a special
electronic inspection. It is known that any produced part which was
inspected electronically has no defects with probability 0.95. For a
part that was not inspected electronically this probability is only
0.7. A customer receives a part and find defects in it. What is the
probability that this part went through an electronic inspection?
Dr. Quratulain Rana
23
References
Probability and Statistics for Computer Scientists, 2nd Edition, Michael Baron
Linear Algebra and Its Applications, 5th Edition, David C. Lay and Steven R. Lay
Introduction to Linear Algebra, 5th Edition, Gilbert Strang
Probability for Computer Scientists, online Edition, David Forsyth.