Expand description
Kendall’s tau rank correlation. Initially the library was based on Apache Commons Math library with some additions taken from scipy and R cor.test function.
Example usage:
let (tau_b, significance) = kendalls::tau_b(&[1, 2, 3], &[3, 4, 5]).unwrap();
assert_eq!(tau_b, 1.0);
assert_eq!(significance, 1.5666989036012806);If you want to compute correlation, let’s say, for f64 type, then 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 (tau_b, _significance) = 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),
).unwrap();
assert_eq!(tau_b, 1.0);The function will return an error if you pass empty arrays into it or x and y arrays’
dimensions are not equal.
Enums§
Functions§
- tau_b
- Implementation of Kendall’s Tau-b rank correlation between two arrays.
- tau_
b_ with_ comparator - The same as
tau_bbut also allow to specify custom comparator for numbers for which Ord trait is not defined.