yat  0.13.2pre
Smoother.h
1 #ifndef _theplu_yat_statistics_smoother_
2 #define _theplu_yat_statistics_smoother_
3 
4 // $Id: Smoother.h 2202 2010-02-21 18:39:13Z peter $
5 
6 /*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010 Peter Johansson
9 
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11 
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16 
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 
27 #include "yat/utility/iterator_traits.h"
28 
29 #include <boost/concept_check.hpp>
30 
31 #include <vector>
32 
33 namespace theplu {
34 namespace yat {
35  namespace regression {
36  class Kernel;
37  }
38 namespace statistics {
39 
45  class Smoother
46  {
47  public:
54  Smoother(const regression::Kernel&, double width,
55  const std::vector<double>& values);
56 
67  Smoother(const regression::Kernel& kernel, double width,
68  double xmin, double xmax, size_t n);
69 
73  void add(double x, double weight=1.0);
74 
78  const std::vector<double>& density(void) const;
79 
85  void rescale(double factor);
86 
90  void reset(void);
91 
95  const std::vector<double>& value(void) const;
96 
97  private:
98  std::vector<double> density_;
99  const regression::Kernel& kernel_;
100  double width_;
101  std::vector<double> x_;
102  };
103 
109  template<typename ForwardIterator>
110  void add(Smoother& h,
111  ForwardIterator first, ForwardIterator last)
112  {
113  BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
115  while (first!=last) {
116  h.add(traits.data(first), traits.weight(first));
117  ++first;
118  }
119  }
120 
126  std::ostream& operator<<(std::ostream& s,const Smoother&);
127 
128 }}} // of namespace statistics, yat, and theplu
129 
130 #endif
Smoother(const regression::Kernel &, double width, const std::vector< double > &values)
data_reference data(Iter iter) const
Definition: iterator_traits.h:440
Definition: iterator_traits.h:412
const std::vector< double > & density(void) const
estimated values
Estimating a distribution in a smooth fashion.
Definition: Smoother.h:45
void add(Smoother &h, ForwardIterator first, ForwardIterator last)
Definition: Smoother.h:110
Interface Class for calculating the weights in a more general way than classical rectangular windows...
Definition: Kernel.h:36
weight_reference weight(Iter iter) const
Definition: iterator_traits.h:446
void reset(void)
reset density to zero
const std::vector< double > & value(void) const
values in which distribution is estimated
void add(double x, double weight=1.0)
Add a data point.

Generated on Wed Jan 4 2017 02:23:07 for yat by  doxygen 1.8.5