Compute the family-wise error rate for m independent uncorrected hypothesis tests
Quick Overview
Write a Python function that returns the family-wise error rate for m independent hypothesis tests run at the same significance level with no correction. It tests the probability reasoning behind multiple comparisons, how the result compares with the m times alpha shortcut, and floating-point care at the edges.
Compute the family-wise error rate for m independent uncorrected hypothesis tests
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: easy
Interview Round: Other
Write `fwer_uncorrected(m, alpha=0.05)` that returns the family-wise error rate: the probability of at least one false positive across `m` independent tests, each run at level `alpha`, when every null hypothesis is true.
The function must follow these rules:
- Use the exact formula `1 - (1 - alpha) ** m`. The `m * alpha` approximation is not accepted.
- Return a Python `float`.
Examples:
```python
fwer_uncorrected(1, 0.05) # -> 0.050000000000000044 (0.05 up to floating-point error)
fwer_uncorrected(10, 0.05) # -> 0.4012630607616213
fwer_uncorrected(20, 0.05) # -> 0.6415140775914581
```
```hint Work with the complement
Start from the chance that none of the m tests produces a false positive, then check your reasoning at m = 1 and at alpha = 1.
```
### Constraints & Assumptions
- `m >= 1` is an integer.
- `0 <= alpha <= 1`.
- The tests are independent and every null hypothesis is true.
### What a Strong Answer Covers
- A derivation of the formula from independence and the complement event.
- The return type and the behavior at the edges: m = 1, alpha = 0 and alpha = 1.
- How the exact rate compares with `m * alpha`, and why the approximation overstates it.
- Why the m = 1 result is not exactly 0.05 in floating point, and how to test it.
### Follow-up Questions
- How far apart are the exact rate and `m * alpha` at m = 20, and when is the approximation good enough?
- What per-test level keeps the family-wise error rate at 0.05 across 10 independent tests?
- How does correlation between the tests, such as several metrics measured on the same users, change the family-wise error rate?
- When would you control the false discovery rate instead of the family-wise error rate?
Overview: Write a Python function that returns the family-wise error rate for m independent hypothesis tests run at the same significance level with no correction. It tests the probability reasoning behind multiple comparisons, how the result compares with the m times alpha shortcut, and floating-point care at the edges.
Write fwer_uncorrected(m, alpha=0.05) that returns the family-wise error rate: the probability of at least one false positive across m independent tests, each run at level alpha, when every null hypothesis is true.
The function must follow these rules:
Use the exact formula
1 - (1 - alpha) ** m
. The
m * alpha
approximation is not accepted.
Return a Python
float
.
Examples:
fwer_uncorrected(1, 0.05) # -> 0.050000000000000044 (0.05 up to floating-point error)
fwer_uncorrected(10, 0.05) # -> 0.4012630607616213
fwer_uncorrected(20, 0.05) # -> 0.6415140775914581
Constraints & Assumptions
m >= 1
is an integer.
0 <= alpha <= 1
.
The tests are independent and every null hypothesis is true.
What a Strong Answer Covers Guidance
A derivation of the formula from independence and the complement event.
The return type and the behavior at the edges: m = 1, alpha = 0 and alpha = 1.
How the exact rate compares with
m * alpha
, and why the approximation overstates it.
Why the m = 1 result is not exactly 0.05 in floating point, and how to test it.
Follow-up Questions Guidance
How far apart are the exact rate and
m * alpha
at m = 20, and when is the approximation good enough?
What per-test level keeps the family-wise error rate at 0.05 across 10 independent tests?
How does correlation between the tests, such as several metrics measured on the same users, change the family-wise error rate?
When would you control the false discovery rate instead of the family-wise error rate?