//TODO public static double Calc(BaseVector x, BaseVector y) { int n = x.Length; List <int> valids = new List <int>(); for (int i = 0; i < n; i++) { double xx = x[i]; double yy = y[i]; if (double.IsNaN(xx) || double.IsNaN(yy) || double.IsInfinity(xx) || double.IsInfinity(yy)) { continue; } valids.Add(i); } if (valids.Count < 3) { return(double.NaN); } return(PearsonCorrelationDistance.Calc(ArrayUtils.Rank(x.SubArray(valids)), ArrayUtils.Rank(y.SubArray(valids)))); }
public static double Calc(IList <float> x, IList <float> y) { int n = x.Count; List <int> valids = new List <int>(); for (int i = 0; i < n; i++) { double xx = x[i]; double yy = y[i]; if (double.IsNaN(xx) || double.IsNaN(yy) || double.IsInfinity(xx) || double.IsInfinity(yy)) { continue; } valids.Add(i); } if (valids.Count < 3) { return(double.NaN); } return(PearsonCorrelationDistance.Calc(ArrayUtils.RankF(ArrayUtils.SubArray(x, valids)), ArrayUtils.RankF(ArrayUtils.SubArray(y, valids)))); }