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-attr-zscore
description: Per-row standardized z-score — (value − mean) / stddev via two-pass Welford.
kind: operator
category: ATTR
operator: ATTR_ZSCORE
type: reference
applies_to: process, compose, predict
examples_tags: [outlier-detection, distribution-shape, buffered-pipeline]

Use when

Adds to every row its z-score: how many standard deviations the row’s value sits above or below the mean.

Questions it answers:

  • Which orders are unusually large compared with all orders?
  • How do scores measured on different scales compare once put on one footing?

Use something else:

  • AGG_ZSCORE when you want the centre and spread of each group, not a score per row.

Params

None. Weight (both kinds, same scores; "weight": null opts out): weighted mean and population sd √(Σw(x − μ)²/Σw); a zero / invalid-weight row adds no mass but is still scored.

Inputs

field — admitted types: see ## Contract; decimal128 reads as its float64 echo, packed_bool as 0/1.

  • label — derived field name; default <TYPE>_<field>

Output

One float64 per record — (value − pop_mean) / pop_stddev. Null source → null (counted in n_null), left out of the mean / sd.

Reading the output

  • value: How many standard deviations the row’s value sits from the mean: (value - mean) / standard deviation, with the population standard deviation (dividing by n). 0 is exactly average, 1 is one standard deviation above it.
    • Sign: positive means the row’s value is above the mean; negative means the row’s value is below the mean.
    • Caveat: Rules such as ‘about 95% of rows lie within 2 standard deviations’ hold only for a roughly bell-shaped (normal) field; on a skewed field far more rows can sit beyond 2 on the long side.

Contract

  • Types (field): date, datetime, decimal128, f32, f64, packed_bool, u16, u32, u4, u64, u8; any other scalar type is PULSE_FIELD_TYPE_UNSUPPORTED.
  • Weight: weighted under frequency and probability weights.
  • Streaming: streamable.

Gotchas

  • Two-pass: pre-pass computes mean/stddev over filter-passing rows, then pass 2 emits per row. Orchestrator handles transparently — no full buffering unless paired with a buffered op downstream.
  • Zero stddev (constant field, or one non-null row) → null per row (0/0), counted in n_null; the run warns PULSE_ATTR_ZERO_SPREAD (details n, spread: stddev, reason constant / single_value / no_mass (no weighted mass)) — under --strict it fails with that code. Runtime only: predict cannot see the data.
  • Two-pass attributes are not mergeable: shard archives and parallel decode take the sequential shard iterator, walking every shard for both passes — global standardization.

See