pub struct TDigest { /* private fields */ }Expand description
A digest of a distribution of numbers, for its quantiles: it keeps
roughly compression centroids, and buffers up to eight times as many
values between merges.
Reading it (quantile, count, to_json, …) merges the buffered
values first, as in JS, so those take &self.
Implementations§
Source§impl TDigest
impl TDigest
Sourcepub fn new(compression: f64) -> Self
pub fn new(compression: f64) -> Self
An empty digest. JS’s default compression, 100, keeps p50, p95 and p99 within about 0.5%.
Sourcepub fn from_json(data: &[f64]) -> Result<Self, String>
pub fn from_json(data: &[f64]) -> Result<Self, String>
The digest of its JSON form, [compression, mean, weight, ...]
(TDigest.fromJSON).
Sourcepub fn from_json_value(v: &Value) -> Result<Self, String>
pub fn from_json_value(v: &Value) -> Result<Self, String>
from_json of a JSON value: an array of numbers.
Sourcepub fn compression(&self) -> f64
pub fn compression(&self) -> f64
The compression the digest was made with.
Sourcepub fn add(&mut self, mean: f64, weight: f64)
pub fn add(&mut self, mean: f64, weight: f64)
Adds a value with a weight (1 in JS by default). A weight that isn’t positive and finite is ignored, as is a NaN mean.
Sourcepub fn centroids(&self) -> Vec<(f64, f64)>
pub fn centroids(&self) -> Vec<(f64, f64)>
The processed centroids, as (mean, weight), ascending.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TDigest
impl !RefUnwindSafe for TDigest
impl !Sync for TDigest
impl Forget for TDigest
impl Move for TDigest
impl Send 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