yat  0.14.5pre
AveragerPair.h
1 #ifndef _theplu_yat_statistics_averagerpair_
2 #define _theplu_yat_statistics_averagerpair_
3 
4 // $Id: AveragerPair.h 3550 2017-01-03 05:41:02Z peter $
5 
6 /*
7  Copyright (C) 2004, 2005 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
9  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
10  Copyright (C) 2009, 2010, 2011, 2016 Peter Johansson
11 
12  This file is part of the yat library, http://dev.thep.lu.se/yat
13 
14  The yat library is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License as
16  published by the Free Software Foundation; either version 3 of the
17  License, or (at your option) any later version.
18 
19  The yat library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with yat. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #include "Averager.h"
29 
30 #include "yat/utility/iterator_traits.h"
31 
32 #include <boost/concept_check.hpp>
33 #include <boost/iterator/iterator_concepts.hpp>
34 
35 #include <cmath>
36 #include <utility>
37 
38 namespace theplu{
39 namespace yat{
40 namespace statistics{
41 
48  {
49  public:
50 
54  AveragerPair(void);
55 
59  AveragerPair(const AveragerPair&);
60 
64  void add(const double x, const double y, const long n=1);
65 
73  double ccc(void) const;
74 
81  double correlation(void) const;
82 
90  double covariance(void) const;
91 
95  double mean_xy(void) const;
96 
101  double msd(void) const;
102 
106  long n(void) const;
107 
111  void reset(void);
112 
116  double sum_xy(void) const;
117 
122  double sum_squared_deviation(void) const;
123 
127  double sum_xy_centered(void) const;
128 
132  const Averager& x_averager(void) const;
133 
137  const Averager& y_averager(void) const;
138 
142  const AveragerPair& operator=(const AveragerPair& a);
143 
147  const AveragerPair& operator+=(const AveragerPair&);
148 
149  private:
150  Averager x_;
151  Averager y_;
152  double xy_centered_;
153 
154  void xy_add(double mx, double my, double xy_centered, long n);
155  };
156 
170  template <class InputIterator1, class InputIterator2>
171  void add(AveragerPair& ap, InputIterator1 first1, InputIterator1 last1,
172  InputIterator2 first2)
173  {
174  BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<InputIterator1>));
175  BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator1>));
176  BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<InputIterator2>));
177  BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator2>));
178 
181  for ( ; first1 != last1; ++first1, ++first2)
182  ap.add(*first1, *first2);
183  }
184 
185 
186 }}} // of namespace statistics, yat, and theplu
187 
188 #endif
AveragerPair(void)
The default constructor.
Class to calculate simple (first and second moments) averages.
Definition: Averager.h:46
const AveragerPair & operator=(const AveragerPair &a)
The assigment operator.
void add(const double x, const double y, const long n=1)
double sum_squared_deviation(void) const
Class for taking care of mean and covariance of two variables.
Definition: AveragerPair.h:47
void check_iterator_is_unweighted(Iter iter)
check (at compile time) that iterator is unweighted.
Definition: iterator_traits.h:200
void reset(void)
Reset everything to zero.
void add(AveragerPair &ap, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
adding data from two ranges to AveragerPair ap
Definition: AveragerPair.h:171
double ccc(void) const
Concordence correlation coefficient.
const Averager & x_averager(void) const
const Averager & y_averager(void) const
const AveragerPair & operator+=(const AveragerPair &)

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5