yat  0.12.3pre
AveragerPair.h
1 #ifndef _theplu_yat_statistics_averagerpair_
2 #define _theplu_yat_statistics_averagerpair_
3 
4 // $Id: AveragerPair.h 2565 2011-09-26 00:53:48Z 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 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 
34 #include <cmath>
35 #include <utility>
36 
37 namespace theplu{
38 namespace yat{
39 namespace statistics{
40 
47  {
48  public:
49 
53  AveragerPair(void);
54 
58  AveragerPair(const AveragerPair&);
59 
63  void add(const double x, const double y, const long n=1);
64 
72  double ccc(void) const;
73 
80  double correlation(void) const;
81 
89  double covariance(void) const;
90 
94  double mean_xy(void) const;
95 
100  double msd(void) const;
101 
105  long n(void) const;
106 
110  void reset(void);
111 
115  double sum_xy(void) const;
116 
121  double sum_squared_deviation(void) const;
122 
126  double sum_xy_centered(void) const;
127 
131  const Averager& x_averager(void) const;
132 
136  const Averager& y_averager(void) const;
137 
141  const AveragerPair& operator=(const AveragerPair& a);
142 
146  const AveragerPair& operator+=(const AveragerPair&);
147 
148  private:
149  Averager x_;
150  Averager y_;
151  double xy_centered_;
152 
153  void xy_add(double mx, double my, double xy_centered, long n);
154  };
155 
161  template <class InputIterator1, class InputIterator2>
162  void add(AveragerPair& ap, InputIterator1 first1, InputIterator1 last1,
163  InputIterator2 first2)
164  {
165  BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
166  BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
169  for ( ; first1 != last1; ++first1, ++first2)
170  ap.add(*first1, *first2);
171  }
172 
173 
174 }}} // of namespace statistics, yat, and theplu
175 
176 #endif
AveragerPair(void)
The default constructor.
Class to calculate simple (first and second moments) averages.
Definition: Averager.h:45
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:46
void check_iterator_is_unweighted(Iter iter)
check (at compile time) that iterator is unweighted.
Definition: iterator_traits.h:194
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:162
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 Mon Jun 1 2015 12:29:52 for yat by  doxygen 1.8.5