//求方差
public double Var(double[] v)
{
double sum1 = 0;
for (int i = 0; i < v.Length; i++)
{
double temp = v[i] * v[i];
sum1 = sum1 + temp;
}
double sum = 0;
foreach (double d in v)
{
sum = sum + d;
}
double var = sum1 / v.Length - (sum / v.Length) * (sum / v.Length);
return var;
}
计算方差
最新推荐文章于 2023-08-08 16:43:05 发布