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-ks
description: Kolmogorov-Smirnov two-sample distribution test on field partitioned by split_by.
kind: operator
category: TEST
operator: TEST_KS
type: reference
applies_to: process, compose, predict
examples_tags: [hypothesis-test, tier-1-test, nonparametric, two-sample, distribution-shape, buffered-pipeline]

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

Use when

Checks whether a numeric field’s values follow the same distribution in two groups, comparing their whole shape.

Questions it answers:

  • Do order values in the two regions have the same overall distribution?
  • Has the shape of response times changed between the old and new system?

Use something else:

  • TEST_SHAPIRO_WILK when you want to check one field against the normal distribution.

Params

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

NameTypeDefaultDescription
alphafloat0.05In (0, 1). Always two-sided; there is no one-sided form.
partition_bylist—Post-test over 2+ groupers: one run per partition, the rows sharing these leading group keys (default all but the last; [] = one run).
  • weight — frequency only: ECDFs step by Σw, p on the Σw sizes — equals the expanded rows. details add sum_weights beside n (raw rows).

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 = D (sup |F₁(x) − F₂(x)|); p_value two-sided = R ks.test(x, y)$p.value: exact when n₁·n₂ < 10000 (Σw under weights; conditional on ties), else the limiting Kolmogorov distribution. details.groups + per-arm details.n.

Reading the output

  • statistic: D is the largest vertical gap between the two groups’ cumulative distributions, from 0 (identical) to 1 (no overlap at all).
    • Caveat: D is most sensitive to differences near the middle of the distributions and less to differences in the tails.
  • 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.

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 weights only; a probability weight is PULSE_WEIGHT_UNSUPPORTED.
  • Multiplicity: a multiplicity method adds p_adjusted and significant_adjusted beside the raw p; families request (default), compose (inside Compose).
  • Streaming: buffered only.

Gotchas

  • Buffered — both ECDFs must materialize and sort before comparison.
  • Sensitive to distribution shape, not just mean.
  • Only n < 2 per group is refused (PULSE_TEST_INSUFFICIENT_N).
  • Asymptotic p only (n₁·n₂ ≥ 10000, Σw under weights; also the post variant): ≥ 50% of pooled values tied (a weight-w row is a tie of w) → warning PULSE_TEST_TIES_DOMINATE; the limiting p is then conservative. The exact p never warns.
  • Tier-2 variant TEST_KS/two_sample_post runs between two output columns of the result rows. A row with a null in a used column drops listwise (R’s NA default); details.n counts the rows used.

See