vector计算和、均值、方差

 

double sum = std::accumulate(std::begin(resultSet), std::end(resultSet), 0.0);
    double mean =  sum / resultSet.size(); //均值

    double accum  = 0.0;
    std::for_each (std::begin(resultSet), std::end(resultSet), [&](const double d) {
        accum  += (d-mean)*(d-mean);
    });

    double stdev = sqrt(accum/(resultSet.size()-1)); //方差

 

posted @ 2019-08-14 16:56  盖世猪猪侠  阅读(2841)  评论(0编辑  收藏  举报