标签:
static Tuple<double,double,double> ComputeVariance2(double[] a) { double variance = 0; //方差 double sum = 0; //总和 double sum2 = 0; //平方和 int len = a.Length; for (int i = 0; i < len; i++) { sum += a[i]; sum2 += a[i] * a[i]; } variance = sum2 / len - (sum / len) * (sum / len); // 平均数 标准差 方差 return Tuple.Create(sum/len, Math.Sqrt(variance), variance); }
标签:
原文地址:http://www.cnblogs.com/chihirosan/p/5530906.html