DecayingMeanStat
Exponentially decaying weighted mean: Sum(v_i*w_i*decay) / Sum(w_i*decay).
Composes two DecayingSumStats; one for weighted values, one for weights; so that the decay factor cancels in the ratio and the mean reflects only the relative weighting of recent vs. older observations.
Use cases: recency-biased central tendency (rolling average of latencies, recent click-through rate, etc.). Reach for this over com.eignex.kumulant.stat.summary.MeanStat when older observations should fade rather than persist.
Memory: O(1); two DecayingSumStat instances.
Update: O(1) per observation (two DecayingSumStat.update() calls).
Concurrency: Each underlying DecayingSumStat locks its state under every concurrent level. The numerator and denominator are updated and read separately, so concurrent readers can observe a partial pair. After writers finish, both sums include every accepted contribution. Concurrency.None runs without synchronisation.
Constructors
DecayingMeanStat
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.
halfLife
weighting
Time-decay schedule applied to past contributions.
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.