kumulant

SeasonalSmoothingStat

class SeasonalSmoothingStat(val alphaWeighting: DecayWeighting.Alpha, val betaWeighting: DecayWeighting.Alpha, val gammaWeighting: DecayWeighting.Alpha, val period: Int, val mode: SeasonalMode = SeasonalMode.Additive, val phi: Double = 1.0, val concurrency: Concurrency = Concurrency.None) : SeriesStat<SeasonalSmoothingResult> (source)

Triple exponential smoothing (Holt-Winters): adds a seasonal component of period to HoltStat's level/trend recurrence. Supports additive and multiplicative seasonality.

Additive recurrence (with a = correction(alpha, weight) and analogous b, g, and k the current seasonal-slot index):

sOld   = seasons[k]<br>prev   = level<br>level  = a * (value - sOld) + (1 - a) * (prev + phi * trend)<br>trend  = b * (level - prev) + (1 - b) * phi * trend<br>seasons[k] = g * (value - level) + (1 - g) * sOld<br>k      = (k + 1) mod period

Multiplicative is the same shape with subtraction replaced by division and addition by multiplication. The first period updates seed the seasonal vector (additive: from the residual value - level; multiplicative: from value / level, falling back to 1.0 if level == 0.0).

Use cases: short-horizon forecasting of streams with a recurring cycle on top of a level and trend; pairs with HoltStat when no seasonal component is present.

Memory: O(period); three scalar cells plus a season array plus a lock.

Update: O(1); single seasonal slot touched per update.

Concurrency: Order-dependent recurrence, same model as HoltStat and com.eignex.kumulant.stat.decay.EwmaMeanStat. Concurrency.Strict and Concurrency.HighWrite lock the body so each update is atomic; Concurrency.Relaxed drops the lock and the level/trend/seasonal cells race independently with bounded drift; never throws.

Constructors

Link copied to clipboard
constructor(alphaWeighting: DecayWeighting.Alpha, betaWeighting: DecayWeighting.Alpha, gammaWeighting: DecayWeighting.Alpha, period: Int, mode: SeasonalMode = SeasonalMode.Additive, phi: Double = 1.0, concurrency: Concurrency = Concurrency.None)
constructor(alpha: Double, beta: Double, gamma: Double, period: Int, mode: SeasonalMode = SeasonalMode.Additive, phi: Double = 1.0, concurrency: Concurrency = Concurrency.None)

Properties

Link copied to clipboard

Level smoothing factor.

Link copied to clipboard

Per-observation smoothing schedule for the level.

Link copied to clipboard

Trend smoothing factor.

Link copied to clipboard

Per-observation smoothing schedule for the trend.

Link copied to clipboard
open override val concurrency: Concurrency

The thread-safety contract this stat was constructed with. Each stat picks the cell-encoding and lock strategy that honours this contract for its mathematical structure:

Link copied to clipboard

Seasonal smoothing factor.

Link copied to clipboard

Per-observation smoothing schedule for the seasonal vector.

Link copied to clipboard

Seasonal coupling; defaults to SeasonalMode.Additive.

Link copied to clipboard
val period: Int

Length of the seasonal cycle in updates.

Link copied to clipboard
val phi: Double

Trend damping factor in (0, 1]; 1.0 is plain Holt-Winters.

Functions

Link copied to clipboard
open override fun create(concurrency: Concurrency? = null): SeasonalSmoothingStat

Spawn a fresh accumulator with the same configuration. Optionally override the Concurrency; useful for materialising a wire spec at a different concurrency level than the source.

Link copied to clipboard
open override fun merge(values: SeasonalSmoothingResult)

Fold another accumulator's snapshot into this one. The unit of merge is the immutable Result; not a live Stat; which is what lets the merge cross a process boundary. Many workers track slices of the same stream, call read periodically, ship snapshots to a coordinator, and the coordinator merges them in.

Link copied to clipboard
open override fun read(timestampNanos: Long = currentTimeNanos()): SeasonalSmoothingResult

Materialise the current state as an immutable Result. Reads never mutate, so the caller can read as often as it likes without affecting the stream.

Link copied to clipboard
open override fun reset()

Reset the stat to its prior-seeded baseline. Equivalent to constructing a fresh stat with the same configuration, but in place; keeps the same Concurrency and any per-stat tunables.

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

Record an observation with the given weight, stamped at the current time.

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

Record an observation at timestampNanos with the given weight. Stats that consume time (rates, decay, windowing) use this as the ordering signal; pass a monotonic stamp when feeding from a replay log.

SeasonalSmoothingStat

constructor(alphaWeighting: DecayWeighting.Alpha, betaWeighting: DecayWeighting.Alpha, gammaWeighting: DecayWeighting.Alpha, period: Int, mode: SeasonalMode = SeasonalMode.Additive, phi: Double = 1.0, concurrency: Concurrency = Concurrency.None)(source)
constructor(alpha: Double, beta: Double, gamma: Double, period: Int, mode: SeasonalMode = SeasonalMode.Additive, phi: Double = 1.0, concurrency: Concurrency = Concurrency.None)(source)

alphaWeighting

Per-observation smoothing schedule for the level.

alpha

Level smoothing factor.

betaWeighting

Per-observation smoothing schedule for the trend.

beta

Trend smoothing factor.

concurrency

open override val concurrency: Concurrency(source)

The thread-safety contract this stat was constructed with. Each stat picks the cell-encoding and lock strategy that honours this contract for its mathematical structure:

Picked at construction; immutable after.

create

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

Spawn a fresh accumulator with the same configuration. Optionally override the Concurrency; useful for materialising a wire spec at a different concurrency level than the source.

The returned stat is independent: its state starts at the configured baseline, not at the source's current state. Each modality subtype narrows the return type so chaining doesn't lose the modality.

gammaWeighting

Per-observation smoothing schedule for the seasonal vector.

gamma

Seasonal smoothing factor.

merge

open override fun merge(values: SeasonalSmoothingResult)(source)

Fold another accumulator's snapshot into this one. The unit of merge is the immutable Result; not a live Stat; which is what lets the merge cross a process boundary. Many workers track slices of the same stream, call read periodically, ship snapshots to a coordinator, and the coordinator merges them in.

Most stat families implement merge exactly (Chan-style parallel formulas for Welford, cell-wise additions for histograms, cell-wise max for HLL). SGD-based regressors merge approximately; they have no second-moment information for the principled combine. Each stat's KDoc documents its merge semantics.

mode

Seasonal coupling; defaults to SeasonalMode.Additive.

period

Length of the seasonal cycle in updates.

phi

Trend damping factor in (0, 1]; 1.0 is plain Holt-Winters.

read

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

Materialise the current state as an immutable Result. Reads never mutate, so the caller can read as often as it likes without affecting the stream.

Snapshot consistency depends on the configured Concurrency. Under Concurrency.Strict / Concurrency.HighWrite a read locks against writers so coupled cells stay consistent. Under Concurrency.Relaxed the cells race and the snapshot may drift by ULPs of the workload under heavy contention; the drift is bounded and the read never throws.

timestampNanos is the read timestamp. Stats that don't care about time silently drop it; stats that do (rates, decay families, recency, windowed wrappers) use it as the ordering signal.

reset

open override fun reset()(source)

Reset the stat to its prior-seeded baseline. Equivalent to constructing a fresh stat with the same configuration, but in place; keeps the same Concurrency and any per-stat tunables.

update

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

Record an observation at timestampNanos with the given weight. Stats that consume time (rates, decay, windowing) use this as the ordering signal; pass a monotonic stamp when feeding from a replay log.