Find the First Look That Crosses a Pocock Group Sequential Boundary

Quick Overview

Implement the stopping rule of a Pocock group sequential design in Python: turn a constant nominal level into one two-sided z boundary and find the first interim look that crosses it. It tests sequential testing concepts, type I error control across repeated looks, and careful output handling.

Find the First Look That Crosses a Pocock Group Sequential Boundary

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Other

Implement `pocock_constant_boundary_stop(z_stats, c)` in `solution.py`. Given per-look two-sided statistics `z_stats` (in look order) and Pocock's constant nominal level `c` (provided, do not compute it), return the 1-based index of the first look crossing the constant boundary. The function must follow these rules: - Use one boundary for all looks: `z_b = scipy.stats.norm.ppf(1 - c/2)`. - A look crosses if `|z_stats[i]| >= z_b`. - Return the 1-based index as an `int`, or `None` if no look crosses. Example: ```python pocock_constant_boundary_stop(np.array([1.5, 2.1, 2.5, 1.0]), 0.0158) # z_b ~= 2.414 # -> 3 (first look with |z| >= 2.414) ``` ```hint Two-sided The statistics can be negative, and the level `c` is split across both tails. ``` ```hint Output contract Check what you return when no look reaches the boundary, and whether look numbers count from 0 or 1. ``` ### Constraints & Assumptions - `z_stats` holds one statistic per interim look, in the order the looks happen, and each is computed on all data collected up to that look. - The looks are equally spaced in information, which is the setting Pocock's `c` is derived for. - `c` is a two-sided nominal level between 0 and 1, such as 0.0158 for five looks at an overall 0.05. - `numpy` and `scipy` are available. ### What a Strong Answer Covers - Turning the nominal level `c` into a single two-sided z boundary, with `c/2` in each tail. - Comparing absolute values with `>=` in look order and stopping at the first crossing. - The output contract: a 1-based Python `int`, or `None` when no look crosses. - Complexity, plus edge cases such as an empty array, a negative statistic or a value exactly on the boundary. ### Follow-up Questions - How does this differ from an O'Brien-Fleming boundary? - Why must the overall type I error be controlled by choosing `c`? - What changes if the looks are not equally spaced, or the team adds a look that was not planned?

Overview: Implement the stopping rule of a Pocock group sequential design in Python: turn a constant nominal level into one two-sided z boundary and find the first interim look that crosses it. It tests sequential testing concepts, type I error control across repeated looks, and careful output handling.

Nov 24, 2026
easyData ScientistOtherAnalytics & Experimentation
0
0

Implement pocock_constant_boundary_stop(z_stats, c) in solution.py. Given per-look two-sided statistics z_stats (in look order) and Pocock's constant nominal level c (provided, do not compute it), return the 1-based index of the first look crossing the constant boundary.

The function must follow these rules:

  • Use one boundary for all looks: z_b = scipy.stats.norm.ppf(1 - c/2) .
  • A look crosses if |z_stats[i]| >= z_b .
  • Return the 1-based index as an int , or None if no look crosses.

Example:

pocock_constant_boundary_stop(np.array([1.5, 2.1, 2.5, 1.0]), 0.0158)
# z_b ~= 2.414
# -> 3   (first look with |z| >= 2.414)

Constraints & Assumptions

  • z_stats holds one statistic per interim look, in the order the looks happen, and each is computed on all data collected up to that look.
  • The looks are equally spaced in information, which is the setting Pocock's c is derived for.
  • c is a two-sided nominal level between 0 and 1, such as 0.0158 for five looks at an overall 0.05.
  • numpy and scipy are available.

What a Strong Answer Covers Guidance

  • Turning the nominal level c into a single two-sided z boundary, with c/2 in each tail.
  • Comparing absolute values with >= in look order and stopping at the first crossing.
  • The output contract: a 1-based Python int , or None when no look crosses.
  • Complexity, plus edge cases such as an empty array, a negative statistic or a value exactly on the boundary.

Follow-up Questions Guidance

  • How does this differ from an O'Brien-Fleming boundary?
  • Why must the overall type I error be controlled by choosing c ?
  • What changes if the looks are not equally spaced, or the team adds a look that was not planned?