Struct inc_stats::Percentiles [] [src]

pub struct Percentiles { /* fields omitted */ }

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());

Methods

impl Percentiles
[src]

[src]

Create a new Percentiles object with no data

[src]

Add a data point

[src]

Get the number of data points

[src]

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);

[src]

Get a percentile

Linear time.

Examples:

let nums = [1.0, 5.0];
let mut percs: inc_stats::Percentiles = nums.iter().cloned().collect();
let quart = percs.percentile(&0.25).unwrap();
assert!((2.0 - quart).abs() < 1.0e-6);

[src]

Get the median

Linear time.

Examples:

let nums = [1.0, 5.0, 100.0];
let mut percs: inc_stats::Percentiles = nums.iter().cloned().collect();
let med = percs.median().unwrap();
assert!((5.0 - med).abs() < 1.0e-6);

Trait Implementations

impl Debug for Percentiles
[src]

[src]

Formats the value using the given formatter. Read more

impl FromIterator<f64> for Percentiles
[src]

[src]

Creates a value from an iterator. Read more

Auto Trait Implementations

impl Send for Percentiles

impl Sync for Percentiles