Struct kolmogorov_smirnov::ecdf::Ecdf
[−]
[src]
pub struct Ecdf<T: Ord> { /* fields omitted */ }
Methods
impl<T: Ord + Clone> Ecdf<T>
[src]
fn new(samples: &[T]) -> Ecdf<T>
Construct a new representation of a cumulative distribution function for a given sample.
The construction will involve computing a sorted clone of the given sample and may be inefficient or completely prohibitive for large samples. This computation is amortized significantly if there is heavy use of the value function.
Panics
The sample set must be non-empty.
Examples
extern crate kolmogorov_smirnov as ks; let samples = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let ecdf = ks::Ecdf::new(&samples);
fn value(&self, t: T) -> f64
Calculate a value of the empirical cumulative distribution function for a given sample.
Examples
extern crate kolmogorov_smirnov as ks; let samples = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let ecdf = ks::Ecdf::new(&samples); assert_eq!(ecdf.value(4), 0.5);
fn percentile(&self, p: u8) -> T
Calculate a percentile for the sample using the Nearest Rank method.
Panics
The percentile requested must be between 1 and 100 inclusive. In particular, there is no 0-percentile.
Examples
extern crate kolmogorov_smirnov as ks; let samples = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let ecdf = ks::Ecdf::new(&samples); assert_eq!(ecdf.percentile(50), 4);
fn min(&self) -> T
Return the minimal element of the samples.
Examples
extern crate kolmogorov_smirnov as ks; let samples = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let ecdf = ks::Ecdf::new(&samples); assert_eq!(ecdf.min(), 0);
fn max(&self) -> T
Return the maximal element of the samples.
Examples
extern crate kolmogorov_smirnov as ks; let samples = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let ecdf = ks::Ecdf::new(&samples); assert_eq!(ecdf.max(), 9);