Convert cumulative alpha spending into per-look alpha increments
Quick Overview
Convert a cumulative alpha-spending schedule from a group sequential test into the alpha spent at each interim look. Tests turning a cumulative schedule into per-look amounts, handling the first look, checking the total under floating point, and what the per-look alpha means for the experiment.
Convert cumulative alpha spending into per-look alpha increments
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: easy
Interview Round: Other
In a group sequential experiment, an alpha-spending function reports the cumulative type I error spent through each interim look. Implement the function below. Given a non-decreasing 1-D array of cumulative alpha spent per look, return a same-length array of per-look increments: `incr[0] = cumulative_spent[0]` and `incr[k] = cumulative_spent[k] - cumulative_spent[k-1]` for `k >= 1`.
```python
def incremental_alpha_spent(cumulative_spent: np.ndarray) -> np.ndarray:
```
Requirements:
- The increments sum to the final cumulative value.
- Return raw floats (no rounding).
Example (output shown to 13 significant digits):
```python
incremental_alpha_spent(np.array([8.857543832140e-05, 5.574596680784e-03, 2.362512131760e-02, 0.05]))
# -> [8.857543832140e-05, 5.486021242463e-03, 1.805052463682e-02, 2.637487868240e-02]
```
```hint One vectorized call
NumPy can take successive differences of an array in one call, and it can pad the front of the array before it does so. Think about what value belongs in front.
```
### Constraints & Assumptions
- `cumulative_spent` is a 1-D array with one entry per look, in look order.
- Values are non-decreasing.
### What a Strong Answer Covers
- How the first look's increment is defined relative to a starting spend of zero
- A vectorized computation and its time and space complexity
- Why the increments add back up to the final cumulative value, and what floating point does to an exact equality check
- What the per-look increment means in a group sequential design
- Input validation when the sequence is not non-decreasing
### Follow-up Questions
- How would you validate that `cumulative_spent` is non-decreasing?
- Is the increment at look `k` the p-value threshold you compare that look's test against? Why or why not?
- If an interim analysis happens at a different information fraction than planned, what changes in the cumulative and incremental spend?
Overview: Convert a cumulative alpha-spending schedule from a group sequential test into the alpha spent at each interim look. Tests turning a cumulative schedule into per-look amounts, handling the first look, checking the total under floating point, and what the per-look alpha means for the experiment.
In a group sequential experiment, an alpha-spending function reports the cumulative type I error spent through each interim look. Implement the function below. Given a non-decreasing 1-D array of cumulative alpha spent per look, return a same-length array of per-look increments: incr[0] = cumulative_spent[0] and incr[k] = cumulative_spent[k] - cumulative_spent[k-1] for k >= 1.