Changeset 231


Ignore:
Timestamp:
Feb 21, 2005, 3:50:17 PM (17 years ago)
Author:
Peter
Message:

filled incomplete stuff

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Histogram.cc

    r215 r231  
    4242int Histogram::add(const double x, const double w)
    4343{
    44   std::cout << "Histogram::add Jari, check me!" << std::endl;
    45 
    4644  sum_all_.add(x,w);
    4745  if (x<xmin_)
     
    5048    return 1;
    5149 
    52   // Peter fill this.
    53   sum_all_.add(x,w);
     50  sum_histogram_.add(x,w);
     51  histogram_[bin(x)] += w;
    5452  return 0;
    5553}
     
    6260    histogram_[i]/=scale_factor;
    6361}
    64 
    6562
    6663
     
    9491  s << "# histogram max : " << histogram.xmax() << '\n';
    9592  s << "# number of bins: " << histogram.nof_bins() << '\n';
    96   s << "# histogram averager: " << histogram.averager_histogram() << '\n';
    97   s << "#       all averager: " << histogram.averager_all() << '\n';
    98 
     93  s << "# nof points in histogram : "
     94    << histogram.averager_histogram().sum_w() << '\n';
     95  s << "# nof points in total:      "
     96    << histogram.averager_all().sum_w() << '\n';
    9997  s << "# column 1: center of observation bin\n"
    10098    << "# column 2: frequency\n";
     
    102100  for (u_int i=0; i<histogram.nof_bins(); i++) {
    103101    s.width(12);
    104     s << histogram.xmin()+(i+0.5)*histogram.spacing();
     102    s << histogram.observation_value(i);
    105103    s.width(12);
    106104    s << histogram[i] << '\n';
  • trunk/src/Histogram.h

    r215 r231  
    136136
    137137  private:
     138    // Returns zero if outside boundaries
    138139    inline size_t bin(double d)
    139       { std::cout << "Histogram::bin Jari, implement me!" << std::endl; return 0; };
    140 //      { return (((d<xmin_) || (d>xmax_)) ? -1 :
    141 //                static_cast<int>(floor((d-xmin_)/spacing_))); }
     140    { return (((d<xmin_) || (d>xmax_)) ? 0 :
     141              static_cast<size_t>(floor((d-xmin_)/spacing() ))); }
    142142
    143143    std::vector<double> histogram_;
Note: See TracChangeset for help on using the changeset viewer.