【问题标题】:Finding values over (µ + 3 sigma) with Boost::accumulators使用 Boost::accumulators 查找超过 (µ + 3 sigma) 的值
【发布时间】:2013-09-22 22:01:26
【问题描述】:

这是我的问题:我有一个包含数据的二维矩阵。数据是高斯的,我需要找出哪些数据点是极端数据点。作为第一个估计,值 > (µ + 3 sigma) 应该没问题。只是为了确定我是否正确执行以下操作: 我可以将数据添加到累加器,我可以计算 µ,但我怎样才能得到 f** sigma?

【问题讨论】:

    标签: c++ boost statistics probability boost-accumulators


    【解决方案1】:

    你可以从累加器中得到平均值和矩:

    #include <iostream>
    #include <boost/accumulators/accumulators.hpp>
    #include <boost/accumulators/statistics/stats.hpp>
    #include <boost/accumulators/statistics/mean.hpp>
    #include <boost/accumulators/statistics/moment.hpp>
    using namespace boost::accumulators;
    
    int main()
    {
        // Define an accumulator set for calculating the mean and the
        // 2nd moment ...
        accumulator_set<double, stats<tag::mean, tag::moment<2> > > acc;
    
        // push in some data ...
        acc(1.2);
        acc(2.3);
        acc(3.4);
        acc(4.5);
    
        // Display the results ...
        std::cout << "Mean:   " << mean(acc) << std::endl;
        std::cout << "Moment: " << accumulators::moment<2>(acc) << std::endl;
    
        return 0;
    }
    

    但是在 boost 文档中,我们读到这是原始时刻(不是中心时刻):

    计算样本的第N个矩,定义为总和 样本数的 N 次方。

    所以你需要调整这个和here is how to do it(你需要第二个中心矩的 sqrt,mi_2)。 http://en.wikipedia.org/wiki/Moment_(mathematics)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-15
      • 1970-01-01
      • 2017-11-11
      • 2019-08-07
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多