Boost logo

Boost Users :

Subject: Re: [Boost-users] Histogram
From: David Doria (daviddoria_at_[hidden])
Date: 2010-04-28 15:17:17


Thanks Paul, I'll check it out.

Arman helped me get to a working demo (below) but I am still a bit confused.

1) What is the "cache"/"cache size"?
2) Does this line:
  double tqueryP = quantile(acc0, quantile_probability = 0.50 );
tell you the percentage of the input values that fall in the top 50%
of all input values?

Here is the code:

std::vector<double> data(100);
  std::generate(data.begin(), data.end(), data_filler<double>());
  int c = data.size();//cache size for histogramm.

  //create a accumulator.
  accumulator_t_right acc0(
boost::accumulators::tag::tail<right>::cache_size = c );
  //fill accumulator
  for (int j = 0; j < c; ++j)
  {
      acc0(data[j]);
  }
  //ask some questions...
  double tqueryP = quantile(acc0, quantile_probability = 0.50 );
  std::cout << tqueryP << std::endl;

Also, with this code:

1) again, what is the cache_size?
2) Is there a way to get a list of the values that are in each bin? Or
only the percentage of the input values that fall in the bin?

  //create some random data
  std::vector<double> data(100);
  std::generate(data.begin(), data.end(), data_filler<double>());
  int c = data.size();//cache size for histogramm.

  //create a accumulator.
  acc myAccumulator( tag::density::num_bins = 20,
tag::density::cache_size = 10);
  //fill accumulator
  for (int j = 0; j < c; ++j)
  {
      myAccumulator(data[j]);
  }
  //ask some questions...
  //double query = density(myAccumulator);
  histogram_type hist = density(myAccumulator);

  double total = 0.0;

  for( int i = 0; i < hist.size(); i++ )
  {
      std::cout << "Bin lower bound: " << hist[i].first << ", Value: "
<< hist[i].second << std::endl;
      total += hist[i].second;
  }

  std::cout << "Total: " << total << std::endl; //should be 1 (and it is)

Thanks!

David


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