Addition Rule for Events Practice Problem
This data science coding problem helps you practice Probability Fundamentals, addition rule for events, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Probability Fundamentals.
- Problem ID: 224
- Problem key: 224-addition-rule-for-events
- URL: https://datacrack.app/solve/224-addition-rule-for-events
- Difficulty: easy
- Topic: Probability Fundamentals
- Module: Probability
Problem Statement
# 🧩 Addition Rule for Events
---
### 🎯 Goal
Calculate $P(A \cup B)$ when two events may share outcomes.
---
### 📖 Introduction
You already learned:
- $A \cup B$ means outcomes in $A$, in $B$, or in both.
- $A \cap B$ means outcomes that are in both $A$ and $B$.
When two events overlap, adding their probabilities directly can count the shared region twice.
The general relationship is:
$$
P(A \cup B)=P(A)+P(B)-P(A \cap B)
$$
The subtraction removes the extra copy of the overlap.
---
### 📥 Input
- `p_a`: probability of event $A$.
- `p_b`: probability of event $B$.
- `p_intersection`: probability of $A \cap B$.
### 📤 Output
- Return $P(A \cup B)$ rounded to 6 decimals.
---
### 💻 Task
Implement `addition_rule(p_a, p_b, p_intersection)`.
---
### 🧩 Starter Code
```python
def addition_rule(p_a, p_b, p_intersection):
pass
```
---
### 💡 Example
```python
addition_rule(0.6, 0.5, 0.2)
```
Expected output:
```python
0.9
```
---
### ⚠️ Common Mistakes
- Adding $P(A)+P(B)$ without accounting for overlap.
- Subtracting the intersection twice.
- Confusing the union $A \cup B$ with the intersection $A \cap B$.
Starter Code
def addition_rule(p_a, p_b, p_intersection):
pass