Boost logo

Boost Users :

Subject: [Boost-users] [accumulators] density: empty values
From: Robert Kubrick (robertkubrick_at_[hidden])
Date: 2009-05-15 12:38:17


I have the following program:

#include <iostream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/density.hpp>

using namespace boost;
using namespace boost::accumulators;

int main()
{
    typedef iterator_range<std::vector<std::pair<double, double> >::iterator > histogram_type;
    accumulator_set<double, features<tag::density> > acc(tag::density::num_bins = 20,
tag::density::cache_size = 10);

    // push in some data ...
    acc(0.1);
    acc(1.2);
    acc(2.3);
    acc(3.4);
    acc(4.5);
    acc(5.4);
    acc(5.5);
    acc(5.5);
    acc(10);

    // Display the results ...
    histogram_type hist = density(acc);
    for( int i = 0; i < hist.size(); i++ )
      std::cout << "Bin lower bound: " << hist[i].first << ", Value: " << hist[i].second << std::endl;

    return 0;
}

Bin values and indexes don't seem to be initialized:

$ acc_dist
Bin lower bound: 0, Value: 0
Bin lower bound: 0, Value: 0
Bin lower bound: 0, Value: 0
Bin lower bound: 0, Value: 0
Bin lower bound: 0, Value: 0
Bin lower bound: 0, Value: 0
...


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net