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 #include "yat/utility/iterator_traits.h"
00027
00028 #include <vector>
00029
00030 namespace theplu {
00031 namespace yat {
00032 namespace regression {
00033 class Kernel;
00034 }
00035 namespace statistics {
00036
00042 class Smoother
00043 {
00044 public:
00051 Smoother(const regression::Kernel&, double width,
00052 const std::vector<double>& values);
00053
00064 Smoother(const regression::Kernel& kernel, double width,
00065 double xmin, double xmax, size_t n);
00066
00070 void add(double x, double weight=1.0);
00071
00075 const std::vector<double>& density(void) const;
00076
00080 void reset(void);
00081
00085 const std::vector<double>& value(void) const;
00086
00087 private:
00088 std::vector<double> density_;
00089 const regression::Kernel& kernel_;
00090 double width_;
00091 std::vector<double> x_;
00092 };
00093
00097 template<typename ForwardIterator>
00098 void add(Smoother& h,
00099 ForwardIterator first, ForwardIterator last)
00100 {
00101 while (first!=last) {
00102 h.add(utility::iterator_traits<ForwardIterator>().data(),
00103 utility::iterator_traits<ForwardIterator>().weight());
00104 ++first;
00105 }
00106 }
00107
00111 std::ostream& operator<<(std::ostream& s,const Smoother&);
00112
00113 }}}
00114
00115 #endif