yat  0.14.5pre
Smoother.h
1 #ifndef _theplu_yat_statistics_smoother_
2 #define _theplu_yat_statistics_smoother_
3 
4 // $Id: Smoother.h 3550 2017-01-03 05:41:02Z peter $
5 
6 /*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2016 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/concept_check.h"
28 #include "yat/utility/iterator_traits.h"
29 
30 #include <boost/concept_check.hpp>
31 #include <boost/iterator/iterator_concepts.hpp>
32 
33 #include <vector>
34 
35 namespace theplu {
36 namespace yat {
37  namespace regression {
38  class Kernel;
39  }
40 namespace statistics {
41 
47  class Smoother
48  {
49  public:
56  Smoother(const regression::Kernel&, double width,
57  const std::vector<double>& values);
58 
69  Smoother(const regression::Kernel& kernel, double width,
70  double xmin, double xmax, size_t n);
71 
75  void add(double x, double weight=1.0);
76 
80  const std::vector<double>& density(void) const;
81 
87  void rescale(double factor);
88 
92  void reset(void);
93 
97  const std::vector<double>& value(void) const;
98 
99  private:
100  std::vector<double> density_;
101  const regression::Kernel& kernel_;
102  double width_;
103  std::vector<double> x_;
104  };
105 
115  template<typename Iterator>
116  void add(Smoother& h, Iterator first, Iterator last)
117  {
118  BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<Iterator>));
119  BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<Iterator>));
121  while (first!=last) {
122  h.add(traits.data(first), traits.weight(first));
123  ++first;
124  }
125  }
126 
132  std::ostream& operator<<(std::ostream& s,const Smoother&);
133 
134 }}} // of namespace statistics, yat, and theplu
135 
136 #endif
Smoother(const regression::Kernel &, double width, const std::vector< double > &values)
data_reference data(Iter iter) const
Definition: iterator_traits.h:440
Concept check for Data Iterator.
Definition: concept_check.h:228
Definition: iterator_traits.h:412
const std::vector< double > & density(void) const
estimated values
Estimating a distribution in a smooth fashion.
Definition: Smoother.h:47
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 add(Smoother &h, Iterator first, Iterator last)
Definition: Smoother.h:116
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 Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5