xicor 0.1.0

An implementation of Sourav Chatterjee's xi-correlation coefficient
Documentation
b0VIM 9.1�Ytgx��?calcprejunct~alc/Projects/xicor/src/lib.rsutf-8
3210#"! Utp#DzzzadA	�	#��FB��[�
u
%

����u'��E�
�
�
�

{
H




�	�	�	�	G	�nfbTP��pomYX;�
�
m
i
a
I
E
$
�	�	�	�	�	�	�	�	G	��i���POM87���KG?'#���ogcUQ�vM���9������h;:��    }        assert_eq!(argsort(&arr).as_slice(), &idcs);        let idcs = [2, 7, 1, 5, 0, 4, 6, 3];        let arr = [2, -2, -9, 8, 4, 1, 6, -3];    fn test_argsort() {    #[test]    }        assert_eq!(xicorf(&y, &x), 0.06099306099306101);        // function of y - this is a one-to-many relationship        // There is /// ```/// assert_eq!(xi, 0.9375);/////// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y: /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y:/// ```//// ```/// assert_eq!(xi, 0.93/// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = /// /// ```/// as/// /// ```/// ```/// assert_eq!(xi, 0/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(/// ```/// assert_eq!(xi, 0.9375);////// let xi = xi/// ```/// assert_eq!(xi, 0.9375)/// /// ```/// assert_eq!(x/// ```/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y: V/// ```/// assert_eq!(xi, 0.9375);////// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&/// ```/// assert_eq!(xi, 0/// ```/// assert_eq!(xi, 0.//// ```/// assert_eq////// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y:/// ```/// assert_eq!(xi, 0.9375);////// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y: V/// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// let y: /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);/// /// ```/// assert_eq!(xi, 0.9375);////// let xi = xicor(&x, &y);///pub use xicor::*;mod xicor;mod tests;#[cfg(test)]//! xi (given certain repub use xicor::*;mod xicor;mod tests;#[cfg(test)]//! xi (given certain rpub use xicor::*;mod xicor;mod tests;#[cfg(test)]//! xi (given certain reqpub use xicor::*;mod xicor;mod tests;#[cfg(test)]//! - [ ] P-values for testing independence//! - [x] Calculation of the xi coefficient itself//!//! ## Progress//!//!   sorting routines.//!   revealed that 80% of this calculation lay in the standard library's//!   [`xicorf`] was able to process 1,000,000 pairs in 0.33 seconds. Profiling//! - Quite fast. In release mode on a 12-year-old machine (Dell M4700),//!   could be correlated in this manner (lexicographically), for example.//!   themselves, only the ability to compare them. In principle even strings//! - Generic over `Ord`, as xi does not require calculations on the elements//!   two slices containing the data)//! - Extremely simple to use (just call [`xicor()`], [`xicorf()`], etc, with//!//! ## Highlights//!//! of what function that may be.//! close to 1, representing that `y` is strongly a function of `x`, regardless//! measures _linear_ dependence. On the other hand, Chatterjee's xi will be//! Pearson's correlation coefficient will be roughly zero for this data, as it//! distributed from zero to tau. For each one, we compute `y = sin(x)`.//! coefficient. Suppose we have some sequence of random `x` values uniformly//! in a much more general sense than, for example, Pearson's correlation//! Chatterjee's xi provides a measure of one variable's dependence on another//!//! [the original paper](https://arxiv.org/pdf/1909.10140).//! Chatterjee's xi-correlation coefficient, based on//! This crate provides a reasonably efficient implementation of Souravad�
����LK���PO�
�
�
V
U




}    }        assert_eq!(cumulative_gte(&arr).as_slice(), &counts);        let counts = [11, 11, 9, 9, 9, 6, 5, 4, 4, 2, 1];        let arr = [1.1, 1.1, 2.5, 2.5, 2.5, 3., 8., 19., 19., 51.7, 100.];    fn test_cumulative_gte() {    #[test]        }        assert_eq!(cumulative_lte(&arr).as_slice(), &counts);        let counts = [2, 2, 5, 5, 5, 6, 7, 9, 9, 11, 11];        let arr = [1.1, 1.1, 2.5, 2.5, 2.5, 3., 8., 19., 19., 51.7, 51.7];    fn test_cumulative_lte() {    #[test]        }        assert_eq!(permute(&arr, &idcs).as_slice(), &permuted);        let permuted = [-9, -3, -2, 1, 2, 4, 6, 8];        let idcs = [2, 7, 1, 5, 0, 4, 6, 3];        let arr = [2, -2, -9, 8, 4, 1, 6, -3];    fn test_permute() {    #[test]ad��E���gDC#���jGF�
�
�
�
�
�
�
k
j
U
7



����1������P�
�
�
�
�
F

�	�	�	c	]	\	Q	O	N	��w54����������nm$�����yxC�����h���J������l5����{Z76A@    }        assert_eq!(argsort(&arr).as_slice()        if a == b { return true; }    fn eq_within(a: f6                                                    assert_req         assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        l        assert_req(xicorf_no         asse        assert_req(xic        assert_req(xicorf_norm(&x, &y), 0.9910030989, R        assert_req(xicorf_norm(&x, &y), 0.9910030989,         assert_req(xicorf_norm(&x, &y), 0.9910030989, R               asse        assert_req(xico        assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        l        assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        let         assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        let y: V        assert_req(xicorf_norm(&x, &y), 0.9910030989, RT         assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        let y:         assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        assert_req(xicorf_norm(&x, &y), 0.9910030989, RT               asse        assert_req(xicorf_n        assert_req(xicorf_norm(&x, &y), 0.9910030989, R        assert_req(xicorf_norm(&x, &y), 0.9910030989,         assert_req(xicorf_norm(&x, &y), 0.9910030989,               asse        assert_req(xicorf_no        assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        l        assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);        let         assert_req(xicorf_norm(&x, &y), 0.9910030989, RTOL);mmod tests;#[mod tests;}    counts    }        if arr[i+1] == arr[i] { counts[i+1] = counts[i]; }    for i in 0..arr.len()-1 {    let mut counts: Vec<usize> = (1..=arr.len()).rev().collect();fn cumulative_gte<T: PartialEq<T> + Copy>(arr: &[T]) -> Vec<usize> {// equal to it. The array should be sorted before it is passed in.// For every element in the array, count how many elements are greater than or}    counts    }        if arr[i] == arr[i+1] { counts[i] = counts[i+1]; }    for i in (0..arr.len()-1).rev() {    let mut counts: Vec<usize> = (1..=arr.len()).collect();fn cumulative_lte<T: PartialEq<T> + Copy>(arr: &[T]) -> Vec<usize> {// equal to it. The array should be sorted before it is passed in.// For every element in the array, count how many elements are less than or}        .collect()        .map(|&i| arr[i])    idcs.iter()fn permute<T: Copy>(arr: &[T], idcs: &[usize]) -> Vec<T> {// Permute the given array such that arr[n] ends up at idcs[n].}    idcs    idcs.sort_unstable_by_key(|&i| &arr[i]);    let mut idcs: Vec<usize> = (0..arr.len()).collect();fn argsort<T: Ord>(arr: &[T]) -> Vec<usize> {// returned sequence of indices i -> arr[i], the resulting sequence is sorted.// Return the indices that would sort the given array. That is, if you map the}    1.-(n as f64)*(rsum as f64)/(2.*lsum as f64)        .sum::<usize>();        .map(|l| l*(n-l))    let lsum = ls.into_iter()    let n = x.len();        .sum::<usize>();        .map(|win| win[0].abs_diff(win[1]))    let rsum = rs.windows(2)    }        ls[i] = l;        rs[i] = r;    for ((i, r), l) in idcs.into_iter().zip(r_ascending).zip(l_ascending) {    let mut ls = vec![0; x.len()];    let mut rs = vec![0; x.len()];    let l_ascending = cumulative_gte(&y_ascending);    let r_ascending = cumulative_lte(&y_ascending);    let y_ascending = permute(&y_ord, &idcs);    let idcs = argsort(&y_ord);    let y_ord = permute(y, &idcs);    let idcs = argsort(x);    assert!(x.len() == y.len(), "x and y must have the same length");pub fn xicor<T: Ord + Copy>(x: &[T], y: &[T]) -> f64 {ad�
���xd/�������|ON    }       }        assert_eq!(argsort(&arr).as_slice(), &idcs);        let idcs = [2, 7, 1, 5, 0, 4, 6, 3];        let arr = [2, -2, -9, 8, 4, 1, 6, -3];    fn test_argsort() {    #[test]    }        }            );                right: {right}"                left: {left}\n\                "assertion `left ~= right` failed\n\            panic!(        if diff/mean_size > rtol {                let diff = (left-right).abs();        let mean_size = (left.abs()+right.abs())/2.;ad+W����W];               if a == b { return     fn assert_req(left: f64, right: f64, rtol: f64) {    // tolerance of eachother.    // Check whether 2 floating-point values are within the given fractional    }