Tutorials › Group Sequential Methods and Sample Size Re-Estimation › Vectorizing the Survivor-Density Update

Computing Boundaries and Power · Tutorial 247 of 699

Vectorizing the Survivor-Density Update

You will derive a vectorized Gaussian transition update, work through its numerical accounting, and learn when vectorization helps—and when coarse grids or large arrays can mislead.

Advanced 10 min read

What You'll Learn

  • Define the survivor density as an unnormalized density that retains only paths still continuing.
  • Translate a Gaussian transition integral into a weighted matrix–vector product.
  • Apply boundary masks without confusing density values with probability mass.
  • Account for lower crossing, upper crossing, and continuation probabilities.
  • Compare vectorized array operations with scalar loops and alternative integration strategies.
  • Identify grid, truncation, and array-orientation errors using probability checks.

Why Vectorize a Survivor-Density Update?

A recursive boundary calculation repeatedly performs the same operation: take the distribution of states that have survived so far, propagate it through a Gaussian transition, and discard states that cross a stopping boundary. Written as an integral, this is conceptually simple. Written as nested loops over thousands of grid points at every analysis, it can be slow and vulnerable to indexing errors. Vectorization expresses the same calculation as a weighted matrix–vector product, so numerical libraries can perform the repeated arithmetic efficiently.

Vectorization does not change the statistical model or make a coarse grid accurate. Its value is computational organization: the transition, integration, and continuation restriction are explicit array operations, and probability accounting can be checked alongside them.

Model and Discretized Update

Use the canonical score scale \(Y_k\), for which the score at information \(I_k\) has mean \(\theta I_k\) and variance \(I_k\). Here \(\theta\) is the drift under the parameter value being evaluated. Under the independent-increment Gaussian model, conditional on \(Y_k=x\), the next state satisfies

$$ Y_{k+1}\mid Y_k=x \sim N(x+\theta\Delta I_k,\Delta I_k), \qquad \Delta I_k=I_{k+1}-I_k>0. $$

At look \(k+1\), let \(a_{k+1}\) and \(b_{k+1}\) be the lower and upper continuation boundaries on this score scale, with \(a_{k+1}<b_{k+1}\). A path continues if its state lies between them. The boundaries can be obtained by expressing the study's \(Z\)-scale boundaries on the score scale; this tutorial focuses on propagating the density once the boundaries are specified.

Definition: The survivor density \(f_k(x)\) is the unconditional density of \(Y_k=x\) together with the event that the trial has not stopped by look \(k\). It is not normalized to integrate to one. Its integral is the probability of surviving to look \(k\).

Choose source-grid nodes \(x_1,\ldots,x_n\) at look \(k\) and destination-grid nodes \(y_1,\ldots,y_m\) at look \(k+1\). Let \(w_i\) and \(v_j\) be the corresponding quadrature weights. The source probability represented by node \(i\) is approximately \(q_i=w_i f_k(x_i)\). The Gaussian transition density evaluated at each source-destination pair is

$$ K_{ij} = \frac{1}{\sqrt{\Delta I_k}}\, \phi\!\left( \frac{y_j-x_i-\theta\Delta I_k}{\sqrt{\Delta I_k}} \right), $$

where \(\phi\) is the standard normal density. In an array convention with sources in rows and destinations in columns, the propagated density values are

$$ g_j \approx \sum_{i=1}^{n} q_i K_{ij}, \qquad \mathbf g=\mathbf K^{\mathsf T}\mathbf q. $$

The destination continuation mask is \(c_j=1\) when \(a_{k+1}<y_j<b_{k+1}\), and \(c_j=0\) otherwise. The updated survivor density and its quadrature mass are

$$ f_{k+1}(y_j)=c_jg_j, \qquad S_{k+1}\approx \sum_{j=1}^{m}v_j f_{k+1}(y_j). $$

The multiplication by \(w_i\) belongs on the source side because the integral is over source states. The destination weights \(v_j\) are used afterward to integrate the updated density. Keeping these roles distinct is central to implementing the update correctly.

Derivation: From an Integral to an Array Operation

Conditional on survival through look \(k\), the density at the next state before applying its boundary is the integral of the previous survivor density times the transition density. Since \(f_k\) is unnormalized, the integral also remains unconditional with respect to survival.

$$ g(y)= \int f_k(x) \frac{1}{\sqrt{\Delta I_k}} \phi\!\left( \frac{y-x-\theta\Delta I_k}{\sqrt{\Delta I_k}} \right)\,dx. $$

Applying a quadrature rule to this integral at each destination node gives \(g(y_j)\approx\sum_i w_i f_k(x_i)K_{ij}\). Defining \(q_i=w_if_k(x_i)\) turns those repeated sums into \(\mathbf K^{\mathsf T}\mathbf q\). Finally, multiplying each destination value by \(c_j\) enforces the continuation condition. Thus the vectorized update is the discretized integral itself, not a different approximation method.

The array shape provides a useful orientation check: \(\mathbf K\) has \(n\) rows and \(m\) columns, \(\mathbf q\) has length \(n\), and \(\mathbf K^{\mathsf T}\mathbf q\) has length \(m\). If source and destination grids have the same number of nodes, a mistaken transpose can still produce a conformable result, so shape alone is not enough; the source-versus-destination definition of \(K_{ij}\) must also be checked.

Worked Example: A Small Matrix Update

Consider a hypothetical discretized update with three source nodes. Suppose their quadrature-weighted survivor masses are \(\mathbf q=(0.10,0.20,0.15)^{\mathsf T}\), and the transition densities evaluated at four destination nodes are represented by the following illustrative array. The numbers are rounded values for demonstrating the arithmetic; the destination quadrature weights are all 1.

$$ \mathbf K= \begin{pmatrix} 0.3989&0.2420&0.0540&0.0044\\ 0.2420&0.3989&0.2420&0.0540\\ 0.0540&0.2420&0.3989&0.2420 \end{pmatrix}, \qquad \mathbf g=\mathbf K^{\mathsf T}\mathbf q. $$

The four destination densities are calculated by column:

$$ \begin{aligned} g_1&=0.10(0.3989)+0.20(0.2420)+0.15(0.0540)=0.09639,\\ g_2&=0.10(0.2420)+0.20(0.3989)+0.15(0.2420)=0.14028,\\ g_3&=0.10(0.0540)+0.20(0.2420)+0.15(0.3989)=0.11364,\\ g_4&=0.10(0.0044)+0.20(0.0540)+0.15(0.2420)=0.04754. \end{aligned} $$

Suppose the middle two destination nodes are inside the continuation interval, so \(c=(0,1,1,0)\). The masked density is \((0,0.14028,0.11364,0)\), and the grid's continuation mass estimate is \(0.14028+0.11364=0.25392\). This is a density-grid quadrature estimate, not an exact probability: the four-node grid is coarse, and the displayed values are rounded. In a real calculation, use the actual quadrature weights and assess adequacy of the grid rather than assuming this small array captures all probability.

Probability Accounting Alongside the Update

A useful independent check comes from the conditional normal distribution. For source node \(x_i\), define \(\mu_i=x_i+\theta\Delta I_k\) and \(\sigma_\Delta=\sqrt{\Delta I_k}\). The probabilities of crossing below the lower boundary, continuing, and crossing above the upper boundary are

$$ \begin{aligned} p_{L,i}&=\Phi\!\left(\frac{a_{k+1}-\mu_i}{\sigma_\Delta}\right),\\ p_{C,i}&=\Phi\!\left(\frac{b_{k+1}-\mu_i}{\sigma_\Delta}\right) -\Phi\!\left(\frac{a_{k+1}-\mu_i}{\sigma_\Delta}\right),\\ p_{U,i}&=1-\Phi\!\left(\frac{b_{k+1}-\mu_i}{\sigma_\Delta}\right). \end{aligned} $$

For every source state, \(p_{L,i}+p_{C,i}+p_{U,i}=1\), up to numerical rounding. Weighting by the source masses gives the corresponding event probabilities for paths that survived through look \(k\): \(P_L\approx\sum_iq_ip_{L,i}\), \(P_C\approx\sum_iq_ip_{C,i}\), and \(P_U\approx\sum_iq_ip_{U,i}\). Their sum should equal the source survivor mass \(\sum_iq_i\), subject to the accuracy of the source quadrature and arithmetic.

This CDF calculation is a probability-accounting check, not a replacement for evaluating the propagated density at destination nodes. Agreement between \(P_C\) and the destination-grid estimate \(S_{k+1}\) depends on the destination quadrature and grid coverage. The CDF values integrate the normal transition over each boundary-defined region directly; the density update samples the transition across the destination grid.

Worked Example: Vectorized Crossing and Continuation Probabilities

Suppose a hypothetical alternative has \(\theta=0.20\), the information increment is \(\Delta I_k=1\), and two source nodes \(x=(0,1)\) carry survivor masses \(q=(0.30,0.20)\). The next continuation interval is \((-1,1.5)\). The transition standard deviation is \(1\), and the two conditional means are \(0+0.20(1)=0.20\) and \(1+0.20(1)=1.20\).

Using standard normal CDF values, for source 1 the lower crossing probability is \(\Phi(-1.20)=0.1151\), the upper crossing probability is \(1-\Phi(1.30)=0.0968\), and continuation probability is \(0.9032-0.1151=0.7881\). For source 2 these values are \(\Phi(-2.20)=0.0139\), \(1-\Phi(0.30)=0.3821\), and \(0.6179-0.0139=0.6040\), respectively.

Now apply the source masses to the two rows of probabilities:

$$ \begin{aligned} P_L&\approx0.30(0.1151)+0.20(0.0139)=0.03731,\\ P_U&\approx0.30(0.0968)+0.20(0.3821)=0.10546,\\ P_C&\approx0.30(0.7881)+0.20(0.6040)=0.35723. \end{aligned} $$

The source mass is \(0.30+0.20=0.50\), and the three event probabilities sum to \(0.03731+0.10546+0.35723=0.50000\), up to rounding. Thus, under this model and these hypothetical inputs, about 0.0373 of the original trial probability crosses the lower boundary at this transition, about 0.105 of it crosses the upper boundary, and about 0.357 remains in the continuation region.

Implementation, Diagnostics, and Alternatives

In a vectorized implementation, construct the \(n\)-by-\(m\) transition array, multiply its transpose by the source-mass vector, apply the destination mask, and integrate with destination weights. For multiple parameter values, form the appropriate transition array for each drift; the drift changes the conditional means and therefore the kernel. Vectorization removes interpreted loops over individual source-destination pairs, but the calculation still requires order \(nm\) kernel evaluations and multiplications. An array with \(n=m=1200\) has \(1{,}440{,}000\) entries; in double precision this is about \(11.5\) megabytes before temporary arrays are counted.

1
Build source masses.
Multiply each survivor-density value by its source quadrature weight. Confirm that their sum represents the probability of reaching the current look without stopping.
2
Propagate to every destination.
Evaluate the transition density using the correct information increment and drift, then compute \(\mathbf K^{\mathsf T}\mathbf q\). Check that the result has one value per destination node.
3
Apply the continuation mask.
Retain density values only at destination nodes inside the continuation interval. Do not multiply density values by source weights a second time.
4
Integrate and check.
Use destination weights to estimate continuing mass, and independently use conditional CDF probabilities to check lower, upper, and continuing event mass.

A diagnostic discrepancy between the destination-grid continuation mass and the CDF-based continuation probability is not automatically a model failure. It can indicate coarse spacing, insufficient coverage of the state space, inaccurate quadrature, or a boundary mask applied at the wrong nodes. Refine or extend the grid and check whether the estimates stabilize. Also verify that \(\Delta I_k>0\), the boundaries are ordered, the normal density includes its \(1/\sqrt{\Delta I_k}\) factor, and the mask retains the intended interior.

The main alternative is a scalar implementation that loops over source and destination nodes and accumulates the same weighted sums. It is easier to inspect on a tiny grid and can use less peak memory if values are generated as needed, but interpreted loops may be slower. A matrix implementation is often faster and its algebra is compact, while requiring attention to array orientation and memory use. Gaussian quadrature or other quadrature rules concern how integrals are approximated; they can be used with either vectorized or scalar arithmetic. Vectorization itself does not improve the quadrature rule or eliminate truncation error.

For very large grids, storing the full kernel may use substantial memory. Processing destination or source nodes in blocks preserves the same sums without holding every matrix entry at once. More specialized methods can exploit additional structure in equally spaced grids, but those methods require their own conditions and numerical checks. The direct matrix update remains a transparent reference calculation.

Common Pitfall: A Density Is Not a Probability Mass

A frequent error is to sum the entries of the propagated density vector and call that the survivor probability. The entries are density values, not probability masses; a sum only approximates an integral when it includes the appropriate destination weights. The correct grid estimate is \(\sum_jv_jc_jg_j\). Conversely, source values must be weighted before propagation, because the source integral is \(\sum_iw_if_k(x_i)K_{ij}\).

Another misleading check is to expect the sampled transition density to integrate to exactly one over a finite grid. A Gaussian transition may put probability outside the grid, and finite-grid quadrature is approximate. Use the CDF partition at the actual stopping boundaries to check event accounting, while remembering that it does not remove approximation in the source survivor density. Probability accounting is meaningful only relative to the mass that reached the transition.

Key takeaway: The survivor update is a weighted transition integral followed by a continuation mask: \(\mathbf f_{k+1}=\mathbf c\odot(\mathbf K^{\mathsf T}(\mathbf w\odot\mathbf f_k))\). Keep source weights, destination weights, and boundary masks in their proper roles, and check crossing plus continuation mass against the source survivor mass.

Check Your Understanding

Answer the questions, then compare your reasoning with the brief solutions.

  1. If there are \(n\) source nodes and \(m\) destination nodes, what are the dimensions of \(\mathbf K\), \(\mathbf q\), and \(\mathbf K^{\mathsf T}\mathbf q\)?
  2. Why is the destination quadrature weight not included in the matrix-vector product that produces \(g_j\)?
  3. Suppose source survivor mass is 0.40 and the weighted lower and upper crossing probabilities are 0.05 and 0.09. What continuation probability should the CDF accounting give?
  4. What does it suggest if the destination-grid continuation mass changes substantially when the destination grid is refined, but the source grid is unchanged?
  5. For \(\Delta I_k=4\), what are the conditional transition variance and standard deviation?

Solutions. (1) \(\mathbf K\) is \(n\)-by-\(m\), \(\mathbf q\) has length \(n\), and the product has length \(m\). (2) The product evaluates the transition integral at each destination node; destination weights are needed when integrating those resulting density values over destination states. (3) Continuation probability is \(0.40-0.05-0.09=0.26\), assuming the three regions partition the next state space. (4) The destination quadrature may be too coarse or the grid may not adequately represent the continuation density; assess grid coverage and convergence. (5) The variance is \(\Delta I_k=4\), and the standard deviation is \(\sqrt{4}=2\), in the score-state units.

Clinical Biostats