kumulant

ReliabilityStat

class ReliabilityStat(val numBins: Int, val concurrency: Concurrency = Concurrency.None) : PairedStat<ReliabilityResult> (source)

Reliability diagram primitive for binary probabilistic forecasts. Paired input is (predictedProbability, outcome); predictions are bucketed into numBins equal-width bins across [0, 1]. Outcomes are typically {0, 1} but soft labels and weighted updates work uniformly.

Predictions outside [0, 1] are clamped to the nearest edge bin.

Use cases: calibration diagnostics for probabilistic forecasters; the raw material for reliability diagrams and Expected Calibration Error. Pair with com.eignex.kumulant.stat.score.MseLossStat for the matching proper-scoring number.

Memory: O(numBins); three parallel Double arrays per bin.

Update: O(1) per paired observation (three atomic adds on the destination bin).

Concurrency: Three independent striped atomic adds per update. Lock-free and exact under every Concurrency level; bin assignment is deterministic per prediction and increments commute.

Constructors

ReliabilityStat

constructor(numBins: Int, 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.

numBins

Functions

create

open override fun create(concurrency: Concurrency? = null): ReliabilityStat(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: ReliabilityResult, 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()): ReliabilityResult(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.

validateMerge

open override fun validateMerge(values: ReliabilityResult)(source)

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.

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

Record the pair (x, y) with weight at the current monotonic time.

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

Record the pair (x, y) with weight at timestampNanos.

update

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

Record the pair (x, y) with weight at timestampNanos.