Convert Cumulative Alpha Spend into Nominal Per-Look Z Cutoffs
Quick Overview
Implement a Python function that turns the cumulative alpha spent through each interim look into nominal two-sided z cutoffs for a group sequential test. It tests incremental error spending, two-sided normal quantiles, and how per-look cutoffs relate to the exact Lan-DeMets boundary.
Convert Cumulative Alpha Spend into Nominal Per-Look Z Cutoffs
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: medium
Interview Round: Other
Implement `nominal_z_cutoffs(cumulative_spent: np.ndarray) -> np.ndarray` in `solution.py`. It converts the cumulative alpha spent through each interim look into nominal two-sided critical z-values. Compute `incr = np.diff(cumulative_spent, prepend=0.0)`, then `z_k = scipy.stats.norm.ppf(1 - incr[k] / 2)`.
The function must:
- Return an array the same length as `cumulative_spent`.
- Use the incremental spend, not the cumulative values directly.
- Apply the two-sided quantile `norm.ppf(1 - incr/2)` per look.
- Return raw floats, with no rounding.
Example:
```python
cumulative_spent = [8.857543832140e-05, 5.574596680784e-03,
2.362512131760e-02, 0.05]
nominal_z_cutoffs(cumulative_spent)
# -> [3.919927969080, 2.777017575309, 2.364580076999, 2.220647016436]
```
The exact Lan-DeMets boundary, which needs multivariate normal integration, is out of scope. `numpy` and `scipy.stats` are available.
```hint What each look gets
The input is a running total. Ask how much error a single look is allowed to use on its own, and remember that the first look has nothing before it.
```
```hint Two tails
A two-sided test at level `a` puts `a/2` in each tail. Check your first cutoff by hand against that.
```
### Constraints & Assumptions
- `cumulative_spent` is nondecreasing, its values lie between 0 and 1, and its last entry is the total two-sided alpha (0.05 in the example).
- It may arrive as a plain list or a NumPy array, with one entry per look.
### What a Strong Answer Covers
- Recovering each look's own spend from the running total, including the first look.
- Splitting each increment across two tails and reproducing the example output.
- Why the resulting design keeps the overall type I error at or below the total alpha, and why that makes it conservative.
- What the function returns for a zero increment, a decreasing input, or a list in place of an array.
### Follow-up Questions
- Why is the per-look nominal cutoff conservative relative to the exact boundary?
- How would you compute the exact Lan-DeMets boundary instead?
- An interim look happens at a different information fraction than planned. How does the spending approach adjust, and does this function need to change?
Overview: Implement a Python function that turns the cumulative alpha spent through each interim look into nominal two-sided z cutoffs for a group sequential test. It tests incremental error spending, two-sided normal quantiles, and how per-look cutoffs relate to the exact Lan-DeMets boundary.
Implement nominal_z_cutoffs(cumulative_spent: np.ndarray) -> np.ndarray in solution.py. It converts the cumulative alpha spent through each interim look into nominal two-sided critical z-values. Compute incr = np.diff(cumulative_spent, prepend=0.0), then z_k = scipy.stats.norm.ppf(1 - incr[k] / 2).
The function must:
Return an array the same length as
cumulative_spent
.
Use the incremental spend, not the cumulative values directly.
Apply the two-sided quantile
norm.ppf(1 - incr/2)
per look.
The exact Lan-DeMets boundary, which needs multivariate normal integration, is out of scope. numpy and scipy.stats are available.
Constraints & Assumptions
cumulative_spent
is nondecreasing, its values lie between 0 and 1, and its last entry is the total two-sided alpha (0.05 in the example).
It may arrive as a plain list or a NumPy array, with one entry per look.
What a Strong Answer Covers Guidance
Recovering each look's own spend from the running total, including the first look.
Splitting each increment across two tails and reproducing the example output.
Why the resulting design keeps the overall type I error at or below the total alpha, and why that makes it conservative.
What the function returns for a zero increment, a decreasing input, or a list in place of an array.
Follow-up Questions Guidance
Why is the per-look nominal cutoff conservative relative to the exact boundary?
How would you compute the exact Lan-DeMets boundary instead?
An interim look happens at a different information fraction than planned. How does the spending approach adjust, and does this function need to change?