Independent Events Practice Problem
This data science coding problem helps you practice Independence, independent events, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Independence.
- Problem ID: 237
- Problem key: 237-independent-events
- URL: https://datacrack.app/solve/237-independent-events
- Difficulty: easy
- Topic: Independence
- Module: Probability
Problem Statement
# 🧩 Independent Events
---
### 🎯 Goal
Calculate conditional and intersection probabilities for two independent events.
---
### 📖 Introduction
Two events are **independent** when knowing that one happened does not change the probability of the other.
If $A$ and $B$ are independent, then knowing $B$ happened does not change the probability of $A$:
$$
P(A \mid B)=P(A)
$$
Also, knowing $A$ happened does not change the probability of $B$:
$$
P(B \mid A)=P(B)
$$
There is an equivalent rule for the overlap:
$$
P(A\cap B)=P(A)P(B)
$$
This problem focuses on what independence means, before testing whether events are independent.
---
### 📥 Input
- `p_a`: probability of event $A$.
- `p_b`: probability of event $B$.
### 📤 Output
Return a dictionary:
```python
{
"p_a_given_b": ...,
"p_b_given_a": ...,
"p_intersection": ...
}
```
Round all probability values to 6 decimals.
---
### 💻 Task
Implement `independent_event_probabilities(p_a, p_b)`.
If the events are independent, your function should return:
- $P(A \mid B)$
- $P(B \mid A)$
- $P(A\cap B)$
---
### 🧩 Starter Code
```python
def independent_event_probabilities(p_a, p_b):
pass
```
---
### 💡 Example
```python
independent_event_probabilities(0.4, 0.5)
```
Expected output:
```python
{
"p_a_given_b": 0.4,
"p_b_given_a": 0.5,
"p_intersection": 0.2
}
```
---
### ⚠️ Common Mistakes
- Thinking independent means the events cannot happen together.
- Confusing independence with mutually exclusive events.
- Changing $P(A)$ after learning $B$ happened, even though the events are independent.
Starter Code
def independent_event_probabilities(p_a, p_b):
pass