Function kolmogorov_smirnov::test::test_f64 [] [src]

pub fn test_f64(xs: &[f64], ys: &[f64], confidence: f64) -> TestResult

Perform a two sample Kolmogorov-Smirnov test on given f64 samples.

This is necessary because f64 does not implement Ord in Rust as some elements are incomparable, e.g. NaN. This function wraps the f64s in implementation of Ord which panics on incomparable elements.

The samples currently must have length > 12 elements for the test to be valid. Also, only the 0.95 confidence level is supported initially.

Panics

There are assertion panics if either sequence has <= 12 elements or if confidence is not 0.95.

If any of the f64 elements in the input samples are unorderable, e.g. NaN.

Examples

extern crate kolmogorov_smirnov as ks;

let xs = vec!(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
let ys = vec!(12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0);
let confidence = 0.95;

let result = ks::test_f64(&xs, &ys, confidence);

if result.is_rejected {
    println!("{:?} and {:?} are not from the same distribution with probability {}.",
      xs, ys, result.reject_probability);
}