Skip to main content

QuantileSketch

Trait QuantileSketch 

Source
pub trait QuantileSketch: Sketch {
    type Value: PartialOrd + Clone;

    // Required methods
    fn add(&mut self, value: Self::Value);
    fn quantile(&self, rank: f64) -> Option<Self::Value>;
    fn rank(&self, value: &Self::Value) -> f64;
    fn min(&self) -> Option<Self::Value>;
    fn max(&self) -> Option<Self::Value>;

    // Provided methods
    fn cdf(&self, value: &Self::Value) -> f64 { ... }
    fn median(&self) -> Option<Self::Value> { ... }
    fn quantiles(&self, ranks: &[f64]) -> Vec<Option<Self::Value>> { ... }
}
Expand description

Quantile estimation sketches

Required Associated Types§

Source

type Value: PartialOrd + Clone

The value type being tracked

Required Methods§

Source

fn add(&mut self, value: Self::Value)

Add a value to the sketch

Source

fn quantile(&self, rank: f64) -> Option<Self::Value>

Get quantile value at given rank (0.0 to 1.0)

rank=0.5 returns the median

Source

fn rank(&self, value: &Self::Value) -> f64

Get rank of a value (0.0 to 1.0)

Source

fn min(&self) -> Option<Self::Value>

Get minimum value seen

Source

fn max(&self) -> Option<Self::Value>

Get maximum value seen

Provided Methods§

Source

fn cdf(&self, value: &Self::Value) -> f64

Get CDF value at given point

Source

fn median(&self) -> Option<Self::Value>

Get median (50th percentile)

Source

fn quantiles(&self, ranks: &[f64]) -> Vec<Option<Self::Value>>

Get multiple quantiles at once

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl QuantileSketch for TDigest

Available on crate feature quantiles only.