Function kolmogorov_smirnov::ecdf::ecdf [] [src]

pub fn ecdf<T: Ord>(samples: &[T], t: T) -> f64

Calculate a one-time value of the empirical cumulative distribution function for a given sample.

Computational running time of this function is O(n) but does not amortize across multiple calls like Ecdf::value. This function should only be used in the case that a small number of ECDF values are required for the sample. Otherwise, Ecdf::new should be used to create a structure that takes the upfront O(n log n) sort cost but calculates values in O(log n).

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 value = ks::ecdf(&samples, 4);
assert_eq!(value, 0.5);