Struct inc_stats::Percentiles
source · pub struct Percentiles { /* private fields */ }Expand description
Data percentile struct
This struct stores data to allow efficient computation of percentiles. This struct takes linear space. It implements FromIterator to allow collection.
Examples
let nums = [2.0, 4.0, 8.0];
let mut percs = inc_stats::Percentiles::new();
for num in nums.iter() {
percs.add(num.clone());
}
assert_eq!(3, percs.count());let nums = [2.0, 4.0, 8.0];
let percs: inc_stats::Percentiles = nums.iter().cloned().collect();
assert_eq!(3, percs.count());Implementations
sourceimpl Percentiles
impl Percentiles
sourcepub fn percentiles<I>(&mut self, percentiles: I) -> Option<Vec<f64>>where
I: Iterator<Item = f64>,
pub fn percentiles<I>(&mut self, percentiles: I) -> Option<Vec<f64>>where
I: Iterator<Item = f64>,
Get a number of percentiles
This takes linear time in the number of added data points, and log linear in the number of percentiles. This will be marginally more efficient than calling percentile repeatedly in a bad order.
Examples:
let nums = [1.0, 3.0, 7.0];
let mut percs: inc_stats::Percentiles = nums.iter().cloned().collect();
let quarts = percs.percentiles([0.75, 0.25, 0.5].iter().cloned()).unwrap();
assert!((5.0 - quarts[0]).abs() < 1.0e-6);
assert!((2.0 - quarts[1]).abs() < 1.0e-6);
assert!((3.0 - quarts[2]).abs() < 1.0e-6);Trait Implementations
sourceimpl Debug for Percentiles
impl Debug for Percentiles
sourceimpl Default for Percentiles
impl Default for Percentiles
sourceimpl FromIterator<f64> for Percentiles
impl FromIterator<f64> for Percentiles
sourcefn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = f64>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = f64>,
Creates a value from an iterator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Percentiles
impl Send for Percentiles
impl Sync for Percentiles
impl Unpin for Percentiles
impl UnwindSafe for Percentiles
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more