pub struct TDigest {
pub min: f64,
pub max: f64,
/* private fields */
}Expand description
A t-digest for approximate quantile estimation over streaming data.
§Construction
use oximedia_analytics::quantile::TDigest;
let mut digest = TDigest::new(100.0);
for x in 0..1000 {
digest.add(x as f64);
}
let p50 = digest.quantile(0.5).unwrap();Fields§
§min: f64Running min and max.
max: f64Implementations§
Source§impl TDigest
impl TDigest
Sourcepub fn new(delta: f64) -> Self
pub fn new(delta: f64) -> Self
Create a new t-digest with the given compression parameter.
Typical values: delta = 100 (moderate accuracy, few centroids) to
delta = 1000 (high accuracy, more centroids).
Sourcepub fn add_weighted(&mut self, value: f64, weight: f64)
pub fn add_weighted(&mut self, value: f64, weight: f64)
Add a data point with an explicit weight.
Sourcepub fn quantile(&mut self, q: f64) -> Result<f64, AnalyticsError>
pub fn quantile(&mut self, q: f64) -> Result<f64, AnalyticsError>
Estimate the value at quantile q ∈ [0, 1].
Returns an error if the digest has no data or q is out of range.
Sourcepub fn centroid_count(&self) -> usize
pub fn centroid_count(&self) -> usize
Number of centroids (compactness measure).
Sourcepub fn total_weight(&self) -> f64
pub fn total_weight(&self) -> f64
Total weight (number of points added, including buffered).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TDigest
impl RefUnwindSafe for TDigest
impl Send for TDigest
impl Sync for TDigest
impl Unpin for TDigest
impl UnsafeUnpin for TDigest
impl UnwindSafe for TDigest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more