Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-test-z-two-sample
description: Two-sample z-test on field means across two split_by groups; identical SE to Welch's t-test but p-value via standard normal Φ.
kind: operator
category: TEST
operator: TEST_Z_TWO_SAMPLE
type: reference
applies_to: process, compose, predict
examples_tags: [hypothesis-test, tier-1-test, parametric, two-sample, z, proportion-analysis, streaming-friendly]

Tests emit statistic / p-value / effect size; no Response.Components.

Use when

Large-sample check of whether two groups differ in average, with the p-value read from the normal distribution.

Questions it answers:

  • In a large survey, do the two regions differ in average score?
  • Across thousands of sessions, is average basket size different between the two app versions?

Use something else:

  • TEST_WELCH when either group is small; the t-distribution p-value is more honest there.

Params

alpha is a top-level key; the rest go in params.

NameTypeDefaultDescription
alphafloat0.05Significance level in (0, 1); reject_null when p < alpha.
referencestring—The baseline split_by level, by value: diff and the effect size read other − reference (default: the alphabetically second level). Not a level → PULSE_TEST_REFERENCE_INVALID; unobserved → PULSE_TEST_REFERENCE_MISSING. Detail: test-variant-options.
covariatestring—A numeric pre-period field (CUPED): the test runs on the adjusted y − θ(x − x̄); details add diff_unadjusted, theta, variance_reduction. Needs split_by; else PULSE_TEST_COVARIATE_INVALID. Detail: test-variant-options.
  • weight — per-group moments on w*, SE reads N*_g (Σw frequency, Kish n_eff probability). details add sum_weights (+ n_eff, probability) shaped like n (raw rows); n_eff < 2 warns PULSE_WEIGHT_LOW_NEFF.

Inputs

field (required) — numeric (decimal128 as its float64 echo, packed_bool as 0/1). split_by (required, exactly 2 groups) — categorical (packed_bool levels "0"/"1").

Output

statistic = z = diff over the unpooled (Welch) SE √(s²_a/n_a + s²_b/n_b); p_value two-sided via standard normal Φ; no df. details: groups, per-arm n / mean / variance (sample, n − 1), diff, normal ci_low/ci_high on diff, pooled-SD effect_size.cohens_d.

Reading the output

  • statistic: z: the first group’s mean minus the second’s, in standard errors built from each group’s sample variance, read against the normal distribution. Values far from 0 in either direction are unlikely if the true gap is zero.
  • p_value: a p-value. Below alpha (0.05 unless the request sets another) the result is called significant; that is not the same as important, so read the effect size for how big it is.
  • details.diff: The first group’s mean minus the second’s, in the field’s own units.

Contract

  • Types (field): date, datetime, decimal128, f32, f64, packed_bool, u16, u32, u4, u64, u8; any other scalar type is PULSE_TEST_FIELD_NOT_NUMERIC.
  • Types (split_by): categorical_*, packed_bool; any other scalar type is PULSE_FIELD_TYPE_UNSUPPORTED.
  • Weight: weighted under frequency and probability weights.
  • Multiplicity: a multiplicity method adds p_adjusted and significant_adjusted beside the raw p; families request (default), compose (inside Compose).
  • Streaming: streamable.

Gotchas

  • Streamable — reads the same per-group Welford buckets as the t-tests.
  • statistic and SE equal Welch’s t; p-value differs (Φ vs Student-t). For small n the divergence is non-trivial; predict surfaces no warning — choose intentionally.
  • Use only when n is large per group AND survey conventions demand normal-CDF p.

See