Find the First Efficacy or Futility Boundary Crossed in a Group-Sequential Test

Quick Overview

Implement a readout for a one-sided group-sequential experiment that walks the interim looks and reports the first efficacy or futility boundary crossed. It tests stopping rules, check ordering at a single look, and how binding futility and alpha spending shape the boundaries.

Find the First Efficacy or Futility Boundary Crossed in a Group-Sequential Test

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: medium

Interview Round: Other

Implement `group_sequential_decision` in `solution.py` for a one-sided group-sequential design. Inputs are `z_stats`, efficacy (upper) z-boundaries, and futility (lower) z-boundaries, all in look order and of equal length. Boundaries are given inputs, never computed here. Return a dict describing the first boundary crossed. Requirements: - Iterate looks in order: at each look, check efficacy before futility. - If `z_stats[i] >= efficacy_bounds[i]`, return `{'look': i+1, 'decision': 'efficacy'}`. - Else if `z_stats[i] <= futility_bounds[i]`, return `{'look': i+1, 'decision': 'futility'}`. - The `'look'` value is 1-based. - If no boundary is crossed by the final look, return `{'look': None, 'decision': 'continue'}`. Example: ```python group_sequential_decision( np.array([1.0, 1.8, 2.6]), np.array([4.0, 2.9, 2.4]), np.array([-1.0, 0.0, 1.0]), ) # -> {'look': 3, 'decision': 'efficacy'} ``` ```hint Stopping is final Once a trial stops at a look, later looks are never evaluated. Think about what that means for how the loop ends, and about the one look where both boundaries can sit at the same value. ``` ### Constraints & Assumptions - `z_stats`, `efficacy_bounds` and `futility_bounds` are 1-D numeric arrays of equal length, in look order. - The design is one-sided: large positive z-statistics favor efficacy. - Boundaries are inputs. No boundary or spending calculation happens inside the function. ### What a Strong Answer Covers - A single pass over the looks with an early return at the first crossing. - Efficacy checked before futility at each look, with inclusive comparisons on both sides. - The 1-based look number and the exact dict shape, including the `continue` case. - What a futility decision means in a binding design compared with a non-binding one. ### Follow-up Questions - How would boundary crossing differ for binding vs non-binding futility bounds? - How would you extend this to report the alpha spent at the stopping look? - What goes wrong if you skip the boundaries and compare every interim z-statistic with the fixed-sample critical value?

Overview: Implement a readout for a one-sided group-sequential experiment that walks the interim looks and reports the first efficacy or futility boundary crossed. It tests stopping rules, check ordering at a single look, and how binding futility and alpha spending shape the boundaries.

Nov 24, 2026
mediumData ScientistOtherAnalytics & Experimentation
0
0

Implement group_sequential_decision in solution.py for a one-sided group-sequential design. Inputs are z_stats, efficacy (upper) z-boundaries, and futility (lower) z-boundaries, all in look order and of equal length. Boundaries are given inputs, never computed here. Return a dict describing the first boundary crossed.

Requirements:

  • Iterate looks in order: at each look, check efficacy before futility.
  • If z_stats[i] >= efficacy_bounds[i] , return {'look': i+1, 'decision': 'efficacy'} .
  • Else if z_stats[i] <= futility_bounds[i] , return {'look': i+1, 'decision': 'futility'} .
  • The 'look' value is 1-based.
  • If no boundary is crossed by the final look, return {'look': None, 'decision': 'continue'} .

Example:

group_sequential_decision(
    np.array([1.0, 1.8, 2.6]),
    np.array([4.0, 2.9, 2.4]),
    np.array([-1.0, 0.0, 1.0]),
)
# -> {'look': 3, 'decision': 'efficacy'}

Constraints & Assumptions

  • z_stats , efficacy_bounds and futility_bounds are 1-D numeric arrays of equal length, in look order.
  • The design is one-sided: large positive z-statistics favor efficacy.
  • Boundaries are inputs. No boundary or spending calculation happens inside the function.

What a Strong Answer Covers Guidance

  • A single pass over the looks with an early return at the first crossing.
  • Efficacy checked before futility at each look, with inclusive comparisons on both sides.
  • The 1-based look number and the exact dict shape, including the continue case.
  • What a futility decision means in a binding design compared with a non-binding one.

Follow-up Questions Guidance

  • How would boundary crossing differ for binding vs non-binding futility bounds?
  • How would you extend this to report the alpha spent at the stopping look?
  • What goes wrong if you skip the boundaries and compare every interim z-statistic with the fixed-sample critical value?