T-test aggregation

T-test aggregation #

A single-value metrics aggregation for a Student’s t-test over two numeric fields. Positive values mean a tends to be larger than b.

How it works #

The engine collects every value of a.field and every value of b.field across the bucket’s documents — the two samples grow independently, so a document missing one field still contributes to the other sample — and computes Welch’s two-sample t-statistic:

t = (mean_a - mean_b) / sqrt(var_a/n_a + var_b/n_b)

with sample variances (n - 1 denominator). The result comes back as the usual single value; it is null when either sample holds fewer than two values.

Engine simplifications to know about:

  • type (paired / homoscedastic / heteroscedastic, default heteroscedastic) is parsed but does not change the computation — every request gets the Welch (unequal-variance) evaluation. There is no per-document pairing and no pooled-variance form.
  • Each population’s filter — a way to split one field into two groups — is accepted but currently unused; point a and b at two fields instead.
  • The response carries the t-statistic only, no p-value. Compare against your critical value: for large samples, |t| beyond roughly 2 means the two means differ at about the 95% level.

Both execution paths (column-store fast path and executor path) run the same computation, and a known-answer test pins the arithmetic (Welch t = 4.88498 on the engine’s coverage fixture).

Examples #

Do sale prices differ from quantities in a systematic way?

Over the 120 sales, price averages 27.5 and qty 2.0, so t comes out around 18.78 — far past any threshold, which is what a huge t says about two fields living on different scales.

Use cases #

  • A/B significance screening — do two measures over the same rows differ beyond noise? A |t| near zero says “indistinguishable”.
  • Before/after sanity checks — compare a recomputed field against the stored one to catch ingestion or migration drift.
  • Interactive statistics teaching — one observable number on live playground data makes the t-test concrete.

Parameters for t_test #

  • a
    (Required, object) field — the first numeric field. A filter is accepted here but currently unused.
  • b
    (Required, object) field — the second numeric field. Same note for filter.
  • type
    (Optional, string, default: heteroscedastic) paired, homoscedastic or heteroscedastic. Parsed; every type currently evaluates as the Welch two-sample test.
Calendar October 6, 2026
Edit Edit this page