Changeset 2038


Ignore:
Timestamp:
Aug 25, 2009, 10:53:31 PM (11 years ago)
Author:
Peter
Message:

closes #554 - added function rescale in Histogram.

Location:
trunk/yat/statistics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Histogram.cc

    r2034 r2038  
    66  Copyright (C) 2006 Jari Häkkinen
    77  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    102103  void Histogram::normalize(bool choice)
    103104  {
    104     double scale_factor;
    105105    if (choice)
    106       scale_factor = sum_all_.sum_w();
     106      rescale(1.0/sum_all_.sum_w());
    107107    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  {
    109120    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;
    117122  }
    118123
  • trunk/yat/statistics/Histogram.h

    r2032 r2038  
    145145    double observation_value(const size_t k) const;
    146146
     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
    147154    ///
    148155    /// Set everyting to default values, here it means that everything
Note: See TracChangeset for help on using the changeset viewer.