[−][src]Function rv::misc::ks_two_sample
pub fn ks_two_sample<X>(
xs: &[X],
ys: &[X],
mode: KsMode,
alternative: KsAlternative
) -> Result<(f64, f64), KsError> where
X: Copy + PartialOrd,
Two sample Kolmogorov-Smirnov statistic on two samples.
Heavily inspired by https://github.com/scipy/scipy/blob/v1.4.1/scipy/stats/stats.py#L6087 Exact computations are derived from: Hodges, J.L. Jr., "The Significance Probability of the Smirnov Two-Sample Test," Arkiv fiur Matematik, 3, No. 43 (1958), 469-86.
Example
use rv::misc::{ks_two_sample, KsMode, KsAlternative}; let xs = [ 0.95692026, 1.1348812 , -0.76579239, -0.58065653, -0.05122393, 0.71598754, 1.39873528, 0.42790527, 1.84580764, 0.64228521 ]; let ys = [ 0.6948678 , -0.3741825 , 0.36657279, 1.15834174, -0.32421706, -0.38499295, 1.44976991, 0.2504608 , -0.53694774, 1.42221993 ]; let (stat, alpha) = ks_two_sample(&xs, &ys, KsMode::Auto, KsAlternative::TwoSided).unwrap(); assert::close(stat, 0.3, 1E-8); assert::close(alpha, 0.7869297884777761, 1E-8);