fn calculate_statistic_alt<T: Ord + Clone>(xs: &[T], ys: &[T]) -> f64 {
        assert!(xs.len() > 0 && ys.len() > 0);
        let mut xs_alt = xs.to_vec();
        let mut ys_alt = ys.to_vec();

        let ecdf_xs = Ecdf::new(&mut xs_alt).unwrap();
        let ecdf_ys = Ecdf::new(&mut ys_alt).unwrap();

        let mut statistic = 0.0;

        for x in xs.iter() {
            let diff = (ecdf_xs.value(x.clone()) - ecdf_ys.value(x.clone())).abs();
            if diff > statistic {
                statistic = diff;
            }
        }

        for y in ys.iter() {
            let diff = (ecdf_xs.value(y.clone()) - ecdf_ys.value(y.clone())).abs();
            if diff > statistic {
                statistic = diff;
            }
        }

        statistic
    }
/// Alternative calculation for the test statistic for the two sample
/// Kolmogorov-Smirnov test. This simple implementation is used as a
/// verification check against actual calculation used.
Alternative calculation for the test statistic for the two sample
Kolmogorov-Smirnov test. This simple implementation is used as a
verification check against actual calculation used.
Alternative calculation for the test statistic for the two sample Kolmogorov - Smirnov test . This simple implementation is used as a verification check against actual calculation used .
fn calculate_statistic_alt<T: Ord + Clone>(xs: &[T], ys: &[T]) -> f64 {
        assert!(xs.len() > 0 && ys.len() > 0);
        let mut xs_alt = xs.to_vec();
        let mut ys_alt = ys.to_vec();
        let ecdf_xs = Ecdf::new(&mut xs_alt).unwrap();
        let ecdf_ys = Ecdf::new(&mut ys_alt).unwrap();
        let mut statistic = 0.0;
        for x in xs.iter() {
            let diff = (ecdf_xs.value(x.clone()) - ecdf_ys.value(x.clone())).abs();
            if diff > statistic {
                statistic = diff;
            }
        }
        for y in ys.iter() {
            let diff = (ecdf_xs.value(y.clone()) - ecdf_ys.value(y.clone())).abs();
            if diff > statistic {
                statistic = diff;
            }
        }
        statistic
    }
fn calculate_statistic_alt < T : Ord + Clone > ( xs : & [ T ] , ys : & [ T ] ) -> f64 { assert ! ( xs len ( ) 0 ys len ( ) 0 ) ; let mut xs_alt = xs . to_vec ( ) ; let mut ys_alt = ys . to_vec ( ) ; let ecdf_xs = Ecdf :: new ( & mut xs_alt ) . unwrap ( ) ; let ecdf_ys = Ecdf :: new ( & mut ys_alt ) . unwrap ( ) ; let mut statistic = 0.0 ; for x in xs . iter ( ) { let diff = ( ecdf_xs . value ( x . clone ( ) ) - ecdf_ys . value ( x . clone ( ) ) ) . abs ( ) ; if diff > statistic { statistic = diff ; } } for y in ys . iter ( ) { let diff = ( ecdf_xs . value ( y . clone ( ) ) - ecdf_ys . value ( y . clone ( ) ) ) . abs ( ) ; if diff > statistic { statistic = diff ; } } statistic }
Alternative calculation for the test statistic for the two sample
Kolmogorov-Smirnov test.
Alternative calculation for the test statistic for the two sample Kolmogorov - Smirnov test .
xs
&[T]
ys
&[T]
xs
&[T]
ys
&[T]