FrugalQuantileStat
Frugal-streaming single-quantile estimator.
Keeps one Double of state that drifts toward the target quantile q; the drift magnitude is scaled by stepSize. Cheap and memory-flat but biased and noisy - use DDSketchStat when accuracy matters.
Treats observations as unweighted (one unit step per update regardless of weight); scaling the step by raw weight would let a single high-weight observation overshoot the target catastrophically. merge averages two estimates as a coarse approximation; frugal sketches do not admit a true associative combine. An estimator that has seen nothing adopts the incoming estimate, and an empty incoming snapshot is skipped, so neither seed is averaged in.
Use cases: memory-constrained tracking of a single quantile with no accuracy guarantee; IoT-class deployments, debug-only monitoring. For production quantile work prefer DDSketchStat or TDigestStat.
Memory: O(1); one double estimate plus a lock.
Update: O(1) per observation.
Concurrency: Order-dependent random-walk recurrence. Concurrency.Strict and Concurrency.HighWrite lock each step but do not reproduce a serial reference value; the lock serialises arrival, not order. Concurrency.Relaxed additionally drops the lock; the single-cell estimate can drift under contention. No numerical error bound is guaranteed.
Constructors
FrugalQuantileStat
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.
initialEstimate
Initial estimate seeding the random walk.
q
stepSize
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.