避免溢出求平均值的算法
double getAverage(const std::vector<double>& data) { double avg = 0; for (size_t i = 0; i < data.size(); ++i) { avg = avg + (data[i] - avg) /(i + 1.0); } return avg; }
double getAverage(const std::vector<double>& data) { double avg = 0; for (size_t i = 0; i < data.size(); ++i) { avg = avg + (data[i] - avg) /(i + 1.0); } return avg; }