Lesson 5 of 15
Independence
When Events Don't Influence Each Other
Events and are independent if knowing occurred tells you nothing about :
Equivalently (and more useful in practice):
# Two fair coin flips are independent
p_heads_1 = 0.5
p_heads_2 = 0.5
p_both = p_heads_1 * p_heads_2
print(p_both) # 0.25 — P(HH)
Testing for Independence
Given , , and , events are independent iff:
Mutual Exclusivity ≠ Independence
Mutually exclusive events (where ) are almost never independent (unless one has probability 0). If occurs, definitely cannot — that is dependence.
Your Task
Implement two functions:
are_independent(p_a, p_b, p_ab)— returnsTrueifjoint_independent(p_a, p_b)— returns , rounded to 4 decimal places
Print the independence check, then the joint probability.
Pyodide loading...
Loading...
Click "Run" to execute your code.