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-t
description: One-sample or two-sample Welch t-test on a numeric field; split_by switches to the two-sample variant.
kind: operator
category: TEST
operator: TEST_T
type: reference
applies_to: process, compose, predict
examples_tags: [hypothesis-test, t-test, tier-1-test, parametric, two-sample, one-sample, streaming-friendly]

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

Use when

Checks whether a numeric field’s average differs from a target value, or between two groups (Welch’s version).

Questions it answers:

  • Is the average order value different from our target of 50?
  • Do new and returning customers spend different amounts on average?

Use something else:

  • TEST_PAIRED_T when the same subjects are measured twice, such as before and after.
  • TEST_ANOVA_WELCH when there are three or more groups.

Params

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

NameTypeDefaultDescription
alphafloat0.05Significance level in (0, 1); reject_null when p < alpha.
mufloat0Hypothesized mean, one-sample only; ignored when split_by is set.
referencestring—The baseline split_by level, by value: diff = other − reference (default: the alphabetically second level, so diff = first − second). Codes: test-variant-options.
covariatestring—A numeric pre-period field (CUPED): the test runs on y − θ(x − x̄); needs split_by. Detail: test-variant-options.
varianceenumunequalunequal (Welch) or pooled (Student, var.equal = TRUE); needs split_by. Detail: test-variant-options.
  • weight — moments on w*, N* = Σw (frequency) or Kish n_eff (probability); df = N*−1 (two-sample: Welch df on N*_g), may be fractional. 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 (optional → two-sample Welch) — categorical_u8/u16/u32 or packed_bool (levels "0"/"1").

Output

statistic = t; df; p_value two-sided. One-sample details: mu, n, mean, variance, ci_low/ci_high, effect_size.cohens_d = (mean − mu)/sd. Two-sample: per-group n/mean/variance, diff, CI, pooled-SD cohens_d.

Reading the output

  • statistic: t is the gap between averages measured in standard errors: the sample mean minus the target value (one-sample), or the first group’s mean minus the second’s (two-sample, Welch). 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: Two-sample only: 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

  • Two-sample needs exactly 2 split_by groups, else PULSE_TEST_SPLIT_GROUPS_LT_2.
  • Constant field within a group → PULSE_TEST_VARIANCE_ZERO.
  • n < 2 (per group) → PULSE_TEST_INSUFFICIENT_N.
  • With groups: one result per group, each with group_key; split_by a grouper → PULSE_TEST_SPLIT_GROUPS_LT_2; a too-sparse group → null figures + a warning (statistical-testing).

See