# 2.1.3.2.5 - Conditional Probability

2.1.3.2.5 - Conditional Probability

A conditional probability is the probability of one event occurring given that a second event is known to have occurred. This is communicated using the symbol $$\mid$$ which is read as "given." For example, $$P(A\mid B)$$ is read as "Probability of A given B."

A conditional probability can be computed using a two-way contingency table. In the examples below, note that we're only interested in the events in one row or column.

## Example: PA Resident given Undergraduate

The two-way contingency table below displays Penn State World Campus enrollments from Fall 2019 in terms of academic level (undergraduate and graduate) and state residency (Pennsylvania and non-Pennsylvania).

Two-Way Table of Academic Level and State Residency
Pennsylvania Non-Pennsylvania Total
Total 6010 8677 14687

Given an individual is an undergraduate student, what is the probability they are a Pennsylvania resident?

We know the individual is an undergraduate student, so we will only look at the row containing the 8360 undergraduate students. Of those 8360 undergraduate students, 3757 were Pennsylvania residents.

$$P(PA \mid Undergrad) = \dfrac{3757}{8360}=0.449$$

Given an individual is a Pennsylvania resident, what is the probability they are an undergraduate student?

Note that most cases, $$P(A\mid B) \ne P(B \mid A)$$. This question is different from the first question because the two events are flipped. Here, we know the individual is a Pennsylvania resident, we we will only look at the column containing the 6010 Pennsylvania residents. Of those 6010 Pennsylvania residents, 3757 were undergraduate students.

$$P(Undergrad \mid PA) = \dfrac{3757}{6010}=0.625$$

What proportion of graduate students are Pennsylvania residents?

This question is worded slightly differently, but it is also a conditional probability. This translates to $$P(PA \mid Graduate)$$. Of the 6327 graduate students, 2253 were Pennsylvania residents.

$$P(PA \mid Graduate) = \dfrac{2253}{6327}=0.356$$

## Sensitivity & Specificity

Sensitivity and specificity are two specific types of conditional probabilities that are often applied in situations involving testing (e.g., medical testing for a given condition). Sensitivity is the probability of testing positive given that one actually has the condition. Specificity is the probability of testing negative given that one actually does not have the condition. Ideally, we would like both sensitivity and specificity rates to be high.

## Example: Sensitivity & Specificity

Compute the sensitivity and specificity of the test data presented in the following two-way contingency table.

Two-Way Table of Test Results and Actual Health
Actually Sick Actually Healthy Total
Tested Positive 15 5 20
Tested Negative 2 19 21
Total 17 24 41

Sensitivity is the proportion of all people who were actually sick who tested positive. As a conditional probability, $$P(positive \mid sick)$$. There were 17 people in the sample who were actually sick. Of those, 15 tested positive.

$$Sensitivity = \dfrac{15}{17}=0.882$$

Specificity is the proportion of all people who were actually healthy who tested negative. As a conditional probability, $$P(negative \mid healthy)$$. There were 24 people in the sample who were actually healthy. Of those, 19 tested negative.

$$Specificity = \dfrac {19}{24}=0.792$$

# 2.1.3.2.5.1 - Advanced Conditional Probability Applications

2.1.3.2.5.1 - Advanced Conditional Probability Applications

Conditional probabilities can also be computed using the following formulas. Note that these two formulas are identical, but A and B are switched. Again, if the contingency table is available it is usually most efficient to take the appropriate values from the table, as shown above, as opposed to using these formulas.

Conditional Probability of A Given B
$$P(A\mid B)=\dfrac{P(A \: \cap\: B)}{P(B)}$$
Conditional Probability of B Given A
$$P(B\mid A)=\dfrac{P(A \: \cap\: B)}{P(A)}$$

## Example: Clubs

In a standard 52-card deck, there are 26 black cards including 13 clubs. All clubs are black, therefore there are 13 black clubs.

What is the probability that a randomly selected card is a club given that it is a black card?

We are given that $$P(club)=\frac{13}{52}=0.25$$, $$P(black)=\frac{26}{52}=0.50$$, and  $$P(club \: \cap\: black)=\frac{13}{52}0.25$$

$$P(club\mid black)=\dfrac{P(club \: \cap\: black)}{P(black)}=\dfrac{0.25}{0.50}=0.50$$

Given that a randomly selected card is black, there is a 50% chance that it's a club.

## Independent Events Written as Conditional Probabilities

If events A and B are independent then $$P(A) = P(A \mid B)$$. In other words, whether or not event B occurs does not change the probability of event A occurring.

## Example: Checking for Independence, Aces and Hearts

A card is randomly drawn from a 52-card deck. Are the events of drawing an ace and drawing a heart independent?

In a standard 52-card deck, there are 4 aces and 13 hearts. Therefore $$P(ace)=\frac{4}{52}$$ and $$P(heart)=\frac{13}{52}$$. Out of 13 hearts, 1 is an ace, which translates to $$P(ace \mid heart) = \frac{1}{13}$$.

To determine if these two events are independent we can compare $$P(A)$$ to $$P(A\mid B)$$. If we call being an ace event A and being a heart event B, then we're comparing $$P(ace)$$ to $$P(ace \mid heart)$$.

$$P(ace)=\frac{4}{52}=0.0769$$

$$P(ace \mid heart) = \frac{1}{13}=0.0769$$

These values are identical, therefore we can conclude that the events of drawing an ace and drawing a heart are independent.

 [1] Link ↥ Has Tooltip/Popover Toggleable Visibility