Changeset 231
- Timestamp:
- Feb 21, 2005, 3:50:17 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Histogram.cc
r215 r231 42 42 int Histogram::add(const double x, const double w) 43 43 { 44 std::cout << "Histogram::add Jari, check me!" << std::endl;45 46 44 sum_all_.add(x,w); 47 45 if (x<xmin_) … … 50 48 return 1; 51 49 52 // Peter fill this. 53 sum_all_.add(x,w);50 sum_histogram_.add(x,w); 51 histogram_[bin(x)] += w; 54 52 return 0; 55 53 } … … 62 60 histogram_[i]/=scale_factor; 63 61 } 64 65 62 66 63 … … 94 91 s << "# histogram max : " << histogram.xmax() << '\n'; 95 92 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'; 99 97 s << "# column 1: center of observation bin\n" 100 98 << "# column 2: frequency\n"; … … 102 100 for (u_int i=0; i<histogram.nof_bins(); i++) { 103 101 s.width(12); 104 s << histogram. xmin()+(i+0.5)*histogram.spacing();102 s << histogram.observation_value(i); 105 103 s.width(12); 106 104 s << histogram[i] << '\n'; -
trunk/src/Histogram.h
r215 r231 136 136 137 137 private: 138 // Returns zero if outside boundaries 138 139 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() ))); } 142 142 143 143 std::vector<double> histogram_;
Note: See TracChangeset
for help on using the changeset viewer.