Changeset 2038
 Timestamp:
 Aug 25, 2009, 10:53:31 PM (12 years ago)
 Location:
 trunk/yat/statistics
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/statistics/Histogram.cc
r2034 r2038 6 6 Copyright (C) 2006 Jari Häkkinen 7 7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Peter Johansson 8 9 9 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 102 103 void Histogram::normalize(bool choice) 103 104 { 104 double scale_factor;105 105 if (choice) 106 scale_factor = sum_all_.sum_w();106 rescale(1.0/sum_all_.sum_w()); 107 107 else 108 scale_factor = sum_all_.sum_w()*spacing(); 108 rescale(1.0/sum_all_.sum_w()/spacing()); 109 } 110 111 112 double Histogram::observation_value(const size_t k) const 113 { 114 return xmin_+spacing()*(k+0.5); 115 } 116 117 118 void Histogram::rescale(double factor) 119 { 109 120 for (size_t i=0; i<histogram_.size(); i++) 110 histogram_[i]/=scale_factor; 111 } 112 113 114 double Histogram::observation_value(const size_t k) const 115 { 116 return xmin_+spacing()*(k+0.5); 121 histogram_[i]*=factor; 117 122 } 118 123 
trunk/yat/statistics/Histogram.h
r2032 r2038 145 145 double observation_value(const size_t k) const; 146 146 147 /** 148 multiply value of each bin with \a factor 149 150 \since New in yat 0.6 151 */ 152 void rescale(double factor); 153 147 154 /// 148 155 /// Set everyting to default values, here it means that everything
Note: See TracChangeset
for help on using the changeset viewer.