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-overlay-ks-vs-pop
kind: operator
category: OVERLAY
operator: OVERLAY_KS_VS_POP
description: Kolmogorov-Smirnov distance + p-value comparing the facet NUMERIC distribution against the resolved population.
type: reference
applies_to: facet
examples_tags: [overlay, facet, hypothesis-test, distribution-shape]

Rides on facet overlays. Overlays decorate the host; no Response.Components.

Use when

Kolmogorov-Smirnov test on a numeric facet: checks whether a subset’s distribution departs from a comparison population’s.

Questions it answers:

  • Does this segment’s spend distribution differ from all customers’?
  • Has the shape of response times in this region drifted from the fleet-wide shape?

Use something else:

  • OVERLAY_CHISQ_VS_POP when the field is categorical.
  • TEST_KS when you have two separate groups of raw rows.

Params

NameTypeDefaultDescription
fieldstring—The facet fields entry to score; required with two or more (else PULSE_OVERLAY_PARAM_MISSING); an unlisted one → PULSE_OVERLAY_FIELD_UNKNOWN.

scope must be group. ref.population.cohort required — the comparison-population cohort; other ref arms → PULSE_OVERLAY_REF_INCOMPATIBLE_WITH_SHAPE. level / within must be 0.

Host shape

FACET — numeric fields only; a categorical one → PULSE_OVERLAY_REF_INCOMPATIBLE_WITH_SHAPE (predict too; the χ²-vs-population sibling covers it). p is ks.test’s two-sided p through the row KS test’s port (op-test-ks). Histogram path: ks.test on the bucketised samples (each record at its bucket index, sizes = bin totals), exact conditional on the bucket ties when m·n < 10000, else the limiting form. Percentile path (no tie pattern): the limiting form at sqrt(n_subset·n_pop/(n_subset + n_pop))·D.

Output

SCALAR — payload.scalar carries KS D; layer summary statistic, p_value, parameters.n_subset / n_pop. summary.baseline unset (inferential).

Reading the output

  • scalar: D, also in summary.statistic: the largest vertical gap between the subset’s and the population’s cumulative distributions, from 0 (the same curve) to 1 (no overlap at all).
  • summary.statistic: The same D as scalar.
  • summary.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.
  • summary.parameters.n_pop: The number of rows behind the population’s numeric summary; the other count the percentile path’s p-value uses.

Contract

  • Weight: refused under any weight in force, an instance default included (PULSE_WEIGHT_UNSUPPORTED); weight: null on the slot runs it unweighted.
  • Multiplicity: a multiplicity method adds p_adjusted and significant_adjusted beside the raw p; families layer (default), request, compose (inside Compose).
  • Streaming: buffered only.

Gotchas

  • Empirical-CDF path: histogram (preferred), else percentile-map, else none: null + PULSE_OVERLAY_REF_ZERO.
  • Only the facet summary is compared, never raw values: set include_histogram: true (with a histogram_range) or numeric_percentiles on the request.
  • Empty host or population (n_subset / n_pop 0) → null + PULSE_OVERLAY_REF_ZERO.
  • Mismatched histogram edges fall to the percentile path, else PULSE_OVERLAY_REF_ZERO.

See