yat  0.8.3pre
Smoother.h
00001 #ifndef _theplu_yat_statistics_smoother_
00002 #define _theplu_yat_statistics_smoother_
00003 
00004 // $Id: Smoother.h 2202 2010-02-21 18:39:13Z peter $
00005 
00006 /*
00007   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
00008   Copyright (C) 2009, 2010 Peter Johansson
00009 
00010   This file is part of the yat library, http://dev.thep.lu.se/yat
00011 
00012   The yat library is free software; you can redistribute it and/or
00013   modify it under the terms of the GNU General Public License as
00014   published by the Free Software Foundation; either version 3 of the
00015   License, or (at your option) any later version.
00016 
00017   The yat library is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00020   General Public License for more details.
00021 
00022   You should have received a copy of the GNU General Public License
00023   along with yat. If not, see <http://www.gnu.org/licenses/>.
00024 */
00025 
00026 
00027 #include "yat/utility/iterator_traits.h"
00028 
00029 #include <boost/concept_check.hpp>
00030 
00031 #include <vector>
00032 
00033 namespace theplu {
00034 namespace yat {
00035   namespace regression { 
00036     class Kernel; 
00037   }
00038 namespace statistics {
00039 
00045   class Smoother
00046   {
00047   public:
00054     Smoother(const regression::Kernel&, double width, 
00055              const std::vector<double>& values);
00056 
00067     Smoother(const regression::Kernel& kernel, double width, 
00068              double xmin, double xmax, size_t n);
00069 
00073     void add(double x, double weight=1.0);
00074 
00078     const std::vector<double>& density(void) const;
00079 
00085     void rescale(double factor);
00086 
00090     void reset(void);
00091 
00095     const std::vector<double>& value(void) const;
00096 
00097   private:
00098     std::vector<double> density_;
00099     const regression::Kernel& kernel_;
00100     double width_;
00101     std::vector<double> x_;
00102   };
00103 
00109   template<typename ForwardIterator>
00110   void add(Smoother& h, 
00111            ForwardIterator first, ForwardIterator last)
00112   {
00113     BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
00114     utility::iterator_traits<ForwardIterator> traits;
00115     while (first!=last) {
00116       h.add(traits.data(first), traits.weight(first));
00117       ++first;
00118     }
00119   }
00120 
00126   std::ostream& operator<<(std::ostream& s,const Smoother&);
00127 
00128 }}} // of namespace statistics, yat, and theplu
00129 
00130 #endif

Generated on Thu Dec 20 2012 03:12:58 for yat by  doxygen 1.8.0-20120409