Kendall's tau rank correlation. At this point this is basically a copy-paste from Apache Commons Math library.
Example usage:
let res = kendalls::tau_b(&[1, 2, 3], &[3, 4, 5]);
assert_eq!(res, Ok(1.0));
If you want to compute Kendall's tau for f64
type, than you will have to
provide either a custom comparator function or declare Ord
trait for your custom floating point
numbers type (see float crate).
use std::cmp::Ordering;
let res = kendalls::tau_b_with_comparator(
&[1.0, 2.0],
&[3.0, 4.0],
|a: &f64, b: &f64| a.partial_cmp(&b).unwrap_or(Ordering::Greater),
);
assert_eq!(res, Ok(1.0));
Function may return an error if there you have passed an empty arrays or x
and y
arrays'
dimensions are not equal.