AdwinStat
ADWIN2 (Bifet & Gavaldà, 2007) adaptive-windowing change detector. Maintains an exponential-histogram window of recent observations whose buckets grow as 2^0, 2^1, 2^2, ...; on every update the detector enumerates all bucket boundaries and drops the older half whenever the mean difference exceeds the Bernstein-flavoured Hoeffding bound
eps_cut = sqrt(2/m * sigma_W^2 * ln(2/delta')) + (2/(3m)) * ln(2/delta')with delta' = delta / ln(n), m the harmonic mean of the two side lengths, and sigma_W^2 the variance of the whole window. The window shrinks adaptively as change points are detected; under stationary streams it grows toward the upper memory bound, which is maxBucketsPerSize * log2(window) buckets.
Merge adds the remote change count without reconstructing its adaptive window. This is an approximate roll-up, not replay of the combined ordered observations.
Use cases: drift detection in monitored signals where neither a target value nor a fixed window is known up front (CUSUM and Page-Hinkley sit alongside).
Memory: O(log n) buckets in the steady state; each bucket holds a count / mean / m2 triplet.
Update: O(log n) amortised; the inner change-test loop scans the bucket adjacencies.
Concurrency: Coupled exponential-histogram structure (category 3). The internal lock keeps the multi-bucket update consistent under any Concurrency level above Concurrency.None.
Constructors
AdwinStat
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
maxBucketsPerSize
Maximum number of buckets per power-of-two size class before merging upward.
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.