Opened 13 years ago

Closed 13 years ago

#3038 closed Bugs (wontfix)

[accumulators] Empty histogram

Reported by: Robert Kubrick <robertkubrick@…> Owned by: Eric Niebler
Milestone: Boost 1.40.0 Component: accumulator
Version: Boost 1.38.0 Severity: Problem
Keywords: histogram density Cc:

Description

When the number of samples entered is lower than the cache_size parameter, histogram is not initialized. Example:

  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);

    // 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;

Change History (2)

comment:1 by Eric Niebler, 13 years ago

Component: Noneaccumulator
Status: newassigned

comment:2 by Eric Niebler, 13 years ago

Resolution: wontfix
Status: assignedclosed

According to Matthias Troyer:

It actually makes sense, since the density estimator first needs to collect a certain number of samples before it can make an educated guess about the locations and widths of histogram bins. It does not make sense to inquire the density before that.

Therefore, this is not a bug by by design. I have now documented the precondition on density result extraction, both in the code and in the users' guide (see changelist [53405]).

Note: See TracTickets for help on using tickets.