使用升压在C个采样的矢量++计算平均值和标准偏差 [英] calculate mean and standard deviation from a vector of samples in C++ using boost

查看:235
本文介绍了使用升压在C个采样的矢量++计算平均值和标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法计算使用升压装有样品的载体平均值和标准偏差?
还是我必须创建一个蓄电池和饲料载体导入呢?

Is there a way to calculate mean and standard deviation for a vector containing samples using boost? Or do I have to create an accumulator and feed the vector into it?

推荐答案

使用蓄电池的以计算平均值和标准偏差的方式<一个href=\"http://www.boost.org/doc/libs/release/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.variance\">boost.

Using accumulators is the way to compute means and standard deviations in boost.

  accumulator_set<double, stats<tag::variance> > acc;
  for_each(a_vec.begin(), a_vec.end(), bind<void>(ref(acc), _1));

  cout << mean(acc) << endl;
  cout << sqrt(variance(acc)) << endl;

这篇关于使用升压在C个采样的矢量++计算平均值和标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆