kumulant

PageHinkleyStat

class PageHinkleyStat(val delta: Double = StatDefaults.PAGE_HINKLEY_DELTA, val threshold: Double = StatDefaults.PAGE_HINKLEY_THRESHOLD, val concurrency: Concurrency = Concurrency.None) : SeriesStat<PageHinkleyResult> (source)

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-_t

and 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

constructor(delta: Double = StatDefaults.PAGE_HINKLEY_DELTA, threshold: Double = StatDefaults.PAGE_HINKLEY_THRESHOLD, concurrency: Concurrency = Concurrency.None)(source)

Properties

concurrency

open override val concurrency: Concurrency(source)

Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.

delta

Tolerance absorbing in-control fluctuation; must be >= 0.

threshold

Alarm threshold for either drift; must be >= 0.

Functions

create

open override fun create(concurrency: Concurrency? = null): PageHinkleyStat(source)

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

open override fun merge(values: PageHinkleyResult, timestampNanos: Long = currentTimeNanos())(source)

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

open override fun read(timestampNanos: Long = currentTimeNanos()): PageHinkleyResult(source)

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

open override fun reset()(source)

Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.

Link copied to clipboard
open fun update(value: Double, weight: Double = 1.0)

Record value with weight at the current monotonic time.

open override fun update(value: Double, timestampNanos: Long, weight: Double = 1.0)

Record value with weight at timestampNanos.

Link copied to clipboard

Validate values for merge without changing accumulator state. Containers validate every child before merging any of them. Successful validation checks compatibility; it does not make a concurrent merge transactional.

update

open override fun update(value: Double, timestampNanos: Long, weight: Double = 1.0)(source)

Record value with weight at timestampNanos.