pub struct Quantile<F: Float = f32> { /* private fields */ }Expand description
Running quantile estimator using the P² algorithm.
Maintains an estimate of a single quantile in constant memory (five markers) and constant per-update time. No samples are stored. Accuracy improves with sample count and is generally good for unimodal distributions; for heavy- tailed or multimodal data, exact methods over a buffered window will be more accurate.
q must be in (0, 1) — use min / max from Statistic
for the endpoints.
Reference: Jain & Chlamtac, “The P² Algorithm for Dynamic Calculation of Quantiles and Histograms Without Storing Observations” (1985).
Implementations§
Source§impl<F: Float> Quantile<F>
impl<F: Float> Quantile<F>
pub fn new(q: F) -> Self
pub fn q(&self) -> F
pub fn count(&self) -> u32
Sourcepub fn value(&self) -> Option<F>
pub fn value(&self) -> Option<F>
Current quantile estimate. Returns None before any sample has been added.
For fewer than five samples, falls back to exact linear interpolation over
the buffered values; after five samples, returns the P² estimate.
pub fn add(&mut self, x: F)
pub fn clear(&mut self)
Trait Implementations§
Source§impl<F: Float> Extend<F> for Quantile<F>
impl<F: Float> Extend<F> for Quantile<F>
Source§fn extend<T: IntoIterator<Item = F>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = F>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)