kumulant

CovarianceStat

class CovarianceStat(concurrency: Concurrency = Concurrency.None) : PairedStat<CovarianceResult> (source)

Online covariance and Pearson correlation between two streams.

Derived from UnivariateRegressionStat: the same Chan's parallel algorithm drives accumulation, and CovarianceResult is projected from UnivariateRegressionResult via mapResult.

Use cases: monitoring joint variability and correlation between two scalar streams (input metric vs output, feature drift detection).

Memory: O(1); same as UnivariateRegressionStat.

Update: O(1) per paired observation.

Concurrency: Inherits UnivariateRegressionStat's concurrency model.

Constructors

Link copied to clipboard
constructor(concurrency: Concurrency = Concurrency.None)

Properties

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:

Functions

Link copied to clipboard
open override fun create(concurrency: Concurrency? = null): PairedStat<CovarianceResult>

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: CovarianceResult)

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()): CovarianceResult

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 override fun update(x: Double, y: Double, weight: Double = 1.0)

Record an (x, y) observation with the given weight at the current time.

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

Record an (x, y) observation at timestampNanos with the given weight.

CovarianceStat

constructor(concurrency: Concurrency = Concurrency.None)(source)