Find the first interim look that crosses a group-sequential stopping boundary

Quick Overview

Given per-look z-statistics and precomputed two-sided stopping boundaries, return the first interim look at which an experiment should stop. It tests the group-sequential stopping rule, careful indexing and boundary handling, and why early looks need stricter thresholds.

Find the first interim look that crosses a group-sequential stopping boundary

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Other

Implement `apply_boundary` in Python. `z_stats` holds per-look z-statistics in order and `z_bounds` the same-length precomputed two-sided boundaries (do not compute them). Return the 1-based index of the first look where `abs(z_stats[i]) >= z_bounds[i]`, else `None`. ```python def apply_boundary(z_stats: np.ndarray, z_bounds: np.ndarray) -> int | None: ... ``` Requirements: - Crossing exactly at the boundary stops (`>=`). - The first look is `1`, not `0`. - Return a Python `int` on a crossing, or `None`. Example: ```python apply_boundary(np.array([1.5, 2.0, 2.5, 1.0]), np.array([4.049, 2.863, 2.337, 2.024])) # -> 3 apply_boundary(np.array([0.5, 1.0, 1.5, 2.0]), np.array([4.049, 2.863, 2.337, 2.024])) # -> None ``` ```hint Where it goes wrong The boundaries are already computed, so the work is a comparison per look. Watch the indexing convention, the sign of the statistic, and the type of the value you return. ``` ### What a Strong Answer Covers - Scanning the looks in order and stopping at the first crossing - The two-sided comparison and the case where the statistic lands exactly on the boundary - The 1-based look number and the return types on both paths - Why the boundaries at early looks are higher than the usual 1.96 - Basic input checks, such as arrays of different lengths ### Follow-up Questions - How would you also support an early futility boundary? - What happens to the type I error rate if you compare every look against 1.96 instead of these boundaries? - How would you handle an interim look that happens at a different information fraction than the one the boundaries were planned for?

Overview: Given per-look z-statistics and precomputed two-sided stopping boundaries, return the first interim look at which an experiment should stop. It tests the group-sequential stopping rule, careful indexing and boundary handling, and why early looks need stricter thresholds.

Nov 25, 2026
easyData ScientistOtherAnalytics & Experimentation
0
0

Implement apply_boundary in Python. z_stats holds per-look z-statistics in order and z_bounds the same-length precomputed two-sided boundaries (do not compute them). Return the 1-based index of the first look where abs(z_stats[i]) >= z_bounds[i], else None.

def apply_boundary(z_stats: np.ndarray, z_bounds: np.ndarray) -> int | None:
    ...

Requirements:

  • Crossing exactly at the boundary stops ( >= ).
  • The first look is 1 , not 0 .
  • Return a Python int on a crossing, or None .

Example:

apply_boundary(np.array([1.5, 2.0, 2.5, 1.0]),
               np.array([4.049, 2.863, 2.337, 2.024]))  # -> 3

apply_boundary(np.array([0.5, 1.0, 1.5, 2.0]),
               np.array([4.049, 2.863, 2.337, 2.024]))  # -> None

What a Strong Answer Covers Guidance

  • Scanning the looks in order and stopping at the first crossing
  • The two-sided comparison and the case where the statistic lands exactly on the boundary
  • The 1-based look number and the return types on both paths
  • Why the boundaries at early looks are higher than the usual 1.96
  • Basic input checks, such as arrays of different lengths

Follow-up Questions Guidance

  • How would you also support an early futility boundary?
  • What happens to the type I error rate if you compare every look against 1.96 instead of these boundaries?
  • How would you handle an interim look that happens at a different information fraction than the one the boundaries were planned for?