PairedSumStat
Weighted paired sum (Sum w_i*x_i, Sum w_i*y_i) with accumulated weight.
Each axis uses naive floating-point addition with the same rounding limitations as SumStat.
Use cases: gradient/Hessian aggregation in histogram boosting (one leaf accumulates (Sum g, Sum h, n)), or any two-axis additive flow.
Memory: O(1); three double cells.
Update: O(1) per observation (three atomic adds).
Concurrency: Three independent atomic adds per update; exact under every Concurrency level. A read() interleaved between the writes of a single update can briefly observe partially-applied state, but the per-cell guarantees hold. Concurrency.HighWrite switches the cells to striped adders.
Constructors
PairedSumStat
Properties
concurrency
Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.
Functions
create
Create an independent accumulator at the configured baseline. A null concurrency preserves this accumulator's mode; a non-null value overrides it. Modality subtypes narrow the return type to preserve the input shape.
merge
Fold a compatible snapshot values into this accumulator at timestampNanos. Implementations document whether the combine is exact or approximate and which state the snapshot omits. The source accumulator is unaffected.
Time-dependent statistics, such as windows, place the snapshot at timestampNanos, which must share the clock the caller uses for updates and reads. Time-independent statistics ignore it.
read
Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.
Snapshot consistency depends on the implementation's synchronisation. Locks protect coupled state under Concurrency.Strict and Concurrency.HighWrite; independently updated cells and JVM striped adders can still yield a best-effort snapshot. Concurrency.Relaxed permits drift across coupled cells.
reset
Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.