Probability Rules
Calculating Probabilities Using Contingency Tables
Learning Objectives
Use contingency tables to calculate probabilities.
Possible Calculations Using Contingency Tables:
Contingency tables give us the following values:
- ‘Singular’ probabilities: P(A), P(B), P(Ā), P(B̅), …
- ‘Joint’ probabilities: P(A and B), P(A and B̅), P(Ā and B), P(Ā and B̅), …
We can use these probabilities and our probability rule to calculate many probabilities. Ex:
- P(At least one event occurring):[latex]P(A \text{ or } B) = P(A) + P(B) - P(A \text{ and } B)[/latex]
- P(Neither event occurring):[latex]P(\text{neither }A \text{ nor } B) = P(\overline{A} \text{ and } \overline{B})[/latex]
- P(One event occurring given another event occurred):[latex]P(A|B) = \frac{P(A \text{ and } B)}{P(B)}[/latex]
Calculting Either/Or, Neither/Nor (Exercise)
Let us explore understanding multiple ways to use the table to calculate:
- P(A or B) = P(at least one of event A or B occurs)
- P(neither A nor B) = P(neither event A nor event B occurs)
Example 18.1.1
Problem Setup: Let us continue with the two marketing campaigns example (Example 18.1):
- P(A) = the click-through rate for ad campaign ‘A’
- P(B) = the click-through rate for ad campaign ‘B’
- P(Ā) = probability of people not clicking through after viewing ad ‘A’
- P(B̅) = probability of people not clicking through after viewing ad ‘B’
- The 2×2 (contingency) table for this example is below:
A | not A | Totals | |
B | 0.003 | 0.047 | 0.05 |
not B | 0.017 | 0.933 | 0.95 |
Totals | 0.02 | 0.98 | 1 |
Questions: Use the above table to answer the following:
- What percent of people click through on at least one of the ads?
- What percent of people click through on neither ‘A’ nor ‘B’?
Solution: Click below to reveal the answers (after trying it yourself):
Calculating COnditional Probabilities (Exercise)
To get the conditional/given probabilities:
- Take any of the AND‘s in our table and divide by an overall probabilities.
- Ex: [latex]P(A|B) = \frac{P(A \text{ and } B)}{P(B)}[/latex]
Example 18.1.2
Problem Setup: Let us continue using the table given in Example 18.1.1.
Questions: Calculate the conditional probabilities listed below:
- What percent of people who clicked through on ad ‘A’ then click through on ‘B’?
- Given someone doesn’t click through ‘A’, what is the probability they click through ‘B’?
- Out of those who do not click through on ‘B’, what percent click through on ‘A’?
- Who should the company running these ads target for ad ‘B’? Those who clicked through on ‘A’ or those who did not?
Instructions: Try the questions yourself. Once done, click below to reveal the answers for each part.
Solution # 18.1.2-1 (Click To ReveAL)
Think of what comes ‘first’ in this conditional probability. This event goes behind the line
- In this case, clicking through on ‘A’ comes first.
- So, we are looking for P(B|A)
- Ie: [latex]P(B|A) = \frac{P(A \text{ and } B)}{P(A)}=\frac{0.003}{0.02}= 0.15=15\%[/latex]
- This was actually the probability we were given at the start of this example in the last section!
Solution #18.1.2-2 (Click to reveal)
Not clicking through after viewing ad ‘A’ comes first for this conditional probability.
- Ie: We are looking for P(B| not A) = P(B| Ā)
- [latex]P(B|\overline{A}) = \frac{P(\overline{A} \text{ and } B)}{P(\overline{A})}=\frac{0.047}{0.98}= 0.0480=4.8\%[/latex]
Solution #18.1.2-3 (Click To reveal)
Not clicking through after viewing ad ‘B’ comes first for this conditional probability. Ie:
- We are looking for P(A| not B) = P(A | B̅)
- [latex]P(A|\overline{B}) = \frac{P(A \text{ and } \overline{B})}{P(\overline{B})}=\frac{0.017}{0.95}= 0.0179=1.79\%[/latex]
Solution #18.1.2-4 (Click To reveal)
In questions 1 and 2, we examined the following:
- Percent who clicked on ‘B’ after they clicked on ‘A’= P(B|A) =15%
- Percent who clicked on ‘B’ after not clicking on ‘A’= P(B|Ā) =4.8%
- We can tell that those who clicked on ‘A’ first are quite a bit more likely to click on ‘B’
- So, the company should target those who already clicked on A.
- We will revisit this idea later in the course with ‘Chi-squared’ testing
Key Takeaways (EXERCISE)
Key Takeaways: Calculating Probabilities Using Contingency Tables
Your Own Notes (EXERCISE)
- Are there any notes you want to take from this section? Is there anything you’d like to copy and paste below?
- These notes are for you only (they will not be stored anywhere)
- Make sure to download them at the end to use as a reference