Statistics for Data Science -1
Statistics for Data Science -1
Lecture 7.1: Conditional Probability: Contingency tables
Usha Mohan
Indian Institute of Technology Madras
1/ 11
Statistics for Data Science -1
Learning objectives
1. Understand notion of conditional probability, i.e find the
probability of an event given another event has occurred.
2/ 11
Statistics for Data Science -1
Learning objectives
1. Understand notion of conditional probability, i.e find the
probability of an event given another event has occurred.
2. Distinguish between independent and dependent events.
2/ 11
Statistics for Data Science -1
Learning objectives
1. Understand notion of conditional probability, i.e find the
probability of an event given another event has occurred.
2. Distinguish between independent and dependent events.
3. Solve applications of probability.
2/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
3/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
From tables to probability
I Recall the cell phone usage versus gender example when we
discussed about association between categorical variables and
the concept of relative frequencies.
I Percentages computed within rows or columns of a
contingency table correspond to conditional probabilities
I Convert contingency tables into probabilities, we use the
counts to define probabilities.
4/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Relative frequency
Own a smartphone
Gender No Yes Row total
Female 10 34 44
Male 14 42 56
Column total 24 76 100
5/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Relative frequency
Own a smartphone
Gender No Yes Row total
Female 10 34 44
Male 14 42 56
Column total 24 76 100
Divide each count by 100
5/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Relative frequency
Own a smartphone
Gender No Yes Row total
Female 10 34 44
Male 14 42 56
Column total 24 76 100
Divide each count by 100
Own a smartphone
Gender No Yes Row total
Female 10/100 34/100 44/100
Male 14/100 42/100 56/100
Column total 24/100 76/100 100
5/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Joint probabilities
Own a smartphone
Gender No Yes Row total
Female 0.10 0.34 0.44
Male 0.14 0.42 0.56
Column total 0.24 0.76 100
I Displayed in cells of a contingency table
I Represent the probability of an intersection of two or more
events
I In the example: there are four joint probabilities; e.g.,
I P(Female and Not owning a smartphone) = 0.10
I P(Male and Owning a smartphone) = 0.42
6/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Marginal probability
Own a smartphone
Gender No Yes Row total
Female 0.10 0.34 0.44
Male 0.14 0.42 0.56
Column total 0.24 0.76 100
I Displayed in the margins of a contingency table
I Is the probability of observing an outcome with a single
attribute, regardless of its other attributes
I In the example: There are four marginal probabilities, e.g.,
I P(Female) = 0.10 + 0.34 = 0.44
I P(Owning a smartphone) = 0.34 + 0.42 = 0.76
7/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns a
phone?”
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns a
phone?”
I “Among people who don’t own a phone, how many are male?”
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns a
phone?”
I “Among people who don’t own a phone, how many are male?”
I Recognize the answers
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns a
phone?”
I “Among people who don’t own a phone, how many are male?”
I Recognize the answers
I “among Female buyers, what is the chance a someone owns a
phone?”- row relative frequency
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
I Find conditional probabilities to answer questions like
I “among Female buyers, what is the chance a someone owns a
phone?”
I “Among people who don’t own a phone, how many are male?”
I Recognize the answers
I “among Female buyers, what is the chance a someone owns a
phone?”- row relative frequency
I “Among people who don’t own a phone, how many are
male?”- column relative frequency
8/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
9/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
9/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
I “among Female buyers, what is the chance a someone owns a
phone?”- Restrict sample space to only “Females”- First row
Own a smartphone
Gender No Yes Row total
Female 10/44 34/44 44
Male 14/56 42/56 56
Column total 24/100 76/100 100
9/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
I “among Female buyers, what is the chance a someone owns a
phone?”- Restrict sample space to only “Females”- First row
Own a smartphone
Gender No Yes Row total
Female 10/44 34/44 44
Male 14/56 42/56 56
Column total 24/100 76/100 100
10
P(Doesn’t own a phone|Female) = 44 =
P(Female∩Doesn’t own a phone)
P(Female)
9/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
10/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
10/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
I “Among people who don’t own a phone, how many are
male?”- Restricting sample space to only people who “don’t
own a phone”- First column
Own a smartphone
Gender No Yes Row total
Female 10/24 34/76 44/100
Male 14/24 42/76 56/100
Column total 24 76 100
10/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Conditional probability
We restrict the sample space to a row or column.
I “Among people who don’t own a phone, how many are
male?”- Restricting sample space to only people who “don’t
own a phone”- First column
Own a smartphone
Gender No Yes Row total
Female 10/24 34/76 44/100
Male 14/24 42/76 56/100
Column total 24 76 100
10
P(Female|Doesn’t own a phone) = 24 =
P(Female∩Doesn’t own a phone)
P(Doesn’t own a phone)
10/ 11
Statistics for Data Science -1
Contingency tables: Joint, Marginal, and Conditional probabilities
Section summary
I Revisited contingency tables and introduced notions of
1. Joint probability
2. Marginal probability
3. Conditional probability
11/ 11