cpp-mean-sd

最終更新: 2017-08-05 16:00

    int min = *std::min_element(log.begin(), log.end());
    int max = *std::max_element(log.begin(), log.end());
    double mean = std::accumulate(log.begin(), log.end(), 0) / static_cast<double>(log.size());
    double sq_sum = std::inner_product(log.begin(), log.end(), log.begin(), 0.0);
    double sd = std::sqrt(sq_sum / log.size() - mean * mean);
    std::cout << "mean: " << mean << " sd: " << sd << " min: " << min << " max: " << max << std::endl;