/// <summary> /// compute the covariance /// </summary> /// <param name="s1"></param> /// <param name="s2"></param> /// <returns></returns> public static double cov(NuGenStatistics s1, NuGenStatistics s2) { try { if (s1.length() != s2.length()) { return(double.NaN); } int len = s1.length(); double sum_mul = 0; for (int i = 0; i <= len - 1; i++) { sum_mul += (s1.list[i] * s2.list[i]); } return((sum_mul - len * s1.mean() * s2.mean()) / (len - 1)); } catch (Exception) { return(double.NaN); } }
/// <summary> /// compute the "b" factor of the linear function of design2 /// </summary> /// <param name="design1"></param> /// <param name="design2"></param> /// <returns></returns> public static double b(NuGenStatistics design1, NuGenStatistics design2) { return(design1.mean() - a(design1, design2) * design2.mean()); }
/// <summary> /// compute the "b" factor of the linear function of design /// </summary> /// <param name="design"></param> /// <returns></returns> public double b(NuGenStatistics design) { return(this.mean() - this.a(design) * design.mean()); }