Compute the Bonferroni peeking boundary for K interim looks in an A/B test
Quick Overview
Implement a function that applies a Bonferroni correction across K interim looks of an A/B test and returns the per-look significance level and the two-sided critical z-value. It tests family-wise error control, two-tailed cutoffs and why repeated peeking needs a correction.
Compute the Bonferroni peeking boundary for K interim looks in an A/B test
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: easy
Interview Round: Other
Implement `bonferroni_peeking_boundary(K: int, alpha: float = 0.05) -> tuple`. Apply a Bonferroni correction across `K` interim looks at an experiment so the family-wise error stays at `alpha`. Return `(nominal_alpha, z_cutoff)`: the per-look two-sided significance level and the critical z-value, where a look rejects the null if `|z| >= z_cutoff`.
Requirements:
- `nominal_alpha = alpha / K`.
- `z_cutoff = scipy.stats.norm.ppf(1 - nominal_alpha / 2)`, not `norm.ppf(1 - nominal_alpha)`.
- Return a tuple of plain Python `float` values, unrounded.
Example:
```python
bonferroni_peeking_boundary(5) -> (0.01, 2.5758293035489004)
bonferroni_peeking_boundary(10) -> (0.005, 2.8070337683438114)
```
```hint Two tails
The rule rejects on the absolute value of z, so the per-look level is shared between both tails of the standard normal. Work out which cumulative probability the cutoff sits at before you call the inverse CDF.
```
### Constraints & Assumptions
- `K` is the number of planned interim looks, an integer with `K >= 1`.
- `alpha` is the target family-wise Type I error rate, with `0 < alpha < 1`.
- The statistic at each look is approximately standard normal under the null.
### What a Strong Answer Covers
- Splitting the family-wise budget equally across the looks, and why the union bound keeps the total at or below `alpha`.
- Placing half of the per-look level in each tail because the rejection rule is two-sided.
- Returning plain Python floats with no rounding, so the results match the example values.
- Input checks for `K` and `alpha`, and the numerical behavior when the per-look level gets very small.
- Why Bonferroni is conservative when every look reuses the data accumulated so far.
### Follow-up Questions
- With no correction at all, roughly how much does checking a test five times at the 1.96 cutoff inflate the false positive rate?
- Bonferroni ignores the correlation between interim z-statistics. How do Pocock or O'Brien-Fleming boundaries use it, and which would you choose if early stopping should be rare?
- When `nominal_alpha / 2` is tiny, `1 - nominal_alpha / 2` loses precision and can round to exactly 1.0. How would you compute the cutoff more accurately?
- How does the function change for a one-sided test?
Overview: Implement a function that applies a Bonferroni correction across K interim looks of an A/B test and returns the per-look significance level and the two-sided critical z-value. It tests family-wise error control, two-tailed cutoffs and why repeated peeking needs a correction.
Implement bonferroni_peeking_boundary(K: int, alpha: float = 0.05) -> tuple. Apply a Bonferroni correction across K interim looks at an experiment so the family-wise error stays at alpha. Return (nominal_alpha, z_cutoff): the per-look two-sided significance level and the critical z-value, where a look rejects the null if |z| >= z_cutoff.
K
is the number of planned interim looks, an integer with
K >= 1
.
alpha
is the target family-wise Type I error rate, with
0 < alpha < 1
.
The statistic at each look is approximately standard normal under the null.
What a Strong Answer Covers Guidance
Splitting the family-wise budget equally across the looks, and why the union bound keeps the total at or below
alpha
.
Placing half of the per-look level in each tail because the rejection rule is two-sided.
Returning plain Python floats with no rounding, so the results match the example values.
Input checks for
K
and
alpha
, and the numerical behavior when the per-look level gets very small.
Why Bonferroni is conservative when every look reuses the data accumulated so far.
Follow-up Questions Guidance
With no correction at all, roughly how much does checking a test five times at the 1.96 cutoff inflate the false positive rate?
Bonferroni ignores the correlation between interim z-statistics. How do Pocock or O'Brien-Fleming boundaries use it, and which would you choose if early stopping should be rare?
When
nominal_alpha / 2
is tiny,
1 - nominal_alpha / 2
loses precision and can round to exactly 1.0. How would you compute the cutoff more accurately?
How does the function change for a one-sided test?