PageHinkleyStat
Page-Hinkley change-point detector. Tracks the running mean alongside two one-sided cumulative-drift signals
m+_t = Sum (x_i - mean - delta), M+_t = min m+_t
m-_t = Sum (x_i - mean + delta), M-_t = max m-_tand raises an alarm when m+_t - M+_t > threshold (upward drift) or M-_t - m-_t > threshold (downward drift). The tolerance delta absorbs in-control fluctuation; threshold controls false-alarm rate.
Merge combines counts and means, adopting remote drift while empty and otherwise averaging the drift traces and their baselines. This is an approximate roll-up, not replay of the combined ordered observations.
Use cases: drift detection in monitored signals, model-residual whiteness loss alarms, online change-point detection where CUSUM's known target value is not available.
Memory: O(1); six cells plus a lock.
Update: O(1).
Concurrency: Order-dependent recurrence over coupled cells, same model as com.eignex.kumulant.stat.decay.EwmaVarianceStat. Concurrency.Strict and Concurrency.HighWrite lock the body so each update is atomic; Concurrency.Relaxed drops the lock and the cells race independently with bounded drift; never throws.
Constructors
PageHinkleyStat
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.
delta
threshold
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.