00001 #ifndef _theplu_yat_statistics_smoother_
00002 #define _theplu_yat_statistics_smoother_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 }}}
00129
00130 #endif