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-agg-average
description: Arithmetic mean of a numeric field across the input set.
kind: operator
category: AGG
operator: AGG_AVERAGE
type: reference
applies_to: process, compose, predict
examples_tags: [streaming-friendly, data-quality]

Use when

Average of a numeric field, over all rows or per group.

Questions it answers:

  • What is the average order value?
  • What is the typical rating in each region?

Use something else:

  • AGG_MEDIAN when the field is skewed or has extreme values and you want the typical row.
  • AGG_WEIGHTED_MEAN when rows carry weights.
  • AGG_WELFORD when you also need the spread around the average.

Params

Weight: honours a resolved row weight (weight on the request or slot, or Options.DefaultWeight; "weight": null opts out) — weighted it is Σw·x / Σw. Invalid weights (null, negative, NaN/Inf, fractional under frequency) are excluded and warned (PULSE_WEIGHT_INVALID_ROWS); zero contributes nothing.

Inputs

ParamAccepted field types
Fieldnumeric: u8/u16/u32/u64, f32/f64, decimal128, date, datetime, packed_bool, u4

Output

Scalar float64. Per-group when wired under a grouper.

Components

Weighted slots add floor keys sum_weights (Σw), n_eff (Kish; probability only) and n_weight_invalid; absent ⇒ unweighted. n/n_null stay raw counts. Weighted adds sum_weighted, weighted_mean, m2_weighted, sum_weights_sq, weighted_variance (m2/(Σw−1)).

Universal floor {n, n_null} plus operator-specific:

KeyTypeNotes
sumfloat64Running sum; mean = sum / n
  • Mergeability: Mergeable
  • Streaming: per-chunk emits running mean via (sum, n)

Gotchas

  • Null inputs skipped — mean is over n non-null, not the cohort.
  • decimal128 under any weight in force (default included) → PULSE_WEIGHT_UNSUPPORTED; "weight": null opts out.

See