使用空Boost累加器
Using empty Boost accumulators
我很好奇,从这个代码片段中获得的平均值是多少?累加器为空。
boost::accumulators::accumulator_set<
int,
boost::accumulators::features<boost::accumulators::tag::mean>
> Accumulator;
int Mean = boost::accumulators::mean(Accumulator);
当我测试它时,平均值是非零的。有没有什么方法能告诉我平均值是对一个空数据集取的?为什么"平均值"的结果值不为零?
我在文档中寻找累加器库,但无法找到这个问题的答案。
任何值都是空值集的有效平均值。也就是说,x * 0 = 0
对任何x
都成立。
您可以将count
特性添加到accumulator_set
并查询它是否为0。
您不需要添加count特性,因为mean累加器是基于count和sum累加器
from boost User's Guide:
均值取决于累加器和累加器…平均累加器的结果仅仅是总和累加器的结果除以计数累加器的结果。
所以你只需要验证count大于0:
bool isEmpty = boost::accumulators::count(Accumulator) == 0;
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 如何在boost beast http请求中设置http头
- Boost Spirit,获取迭代器内部语义动作
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 当我尝试使用 sstream 和分面将 Boost Time_duration转换为字符串时,我没有得到所需的格式
- 使用 boost::累加器::统计来查找数组的中位数
- 使用 Boost::累加器查找超过 (μ + 3 西格玛) 的值
- 对Eigen::Vector类型使用Boost累加器
- 使用空Boost累加器
- boost累加器可以用作类成员吗?