00001 #ifndef _theplu_yat_statistics_averagerpair_
00002 #define _theplu_yat_statistics_averagerpair_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "Averager.h"
00029
00030 #include "yat/utility/iterator_traits.h"
00031
00032 #include <boost/concept_check.hpp>
00033
00034 #include <cmath>
00035 #include <utility>
00036
00037 namespace theplu{
00038 namespace yat{
00039 namespace statistics{
00040
00046 class AveragerPair
00047 {
00048 public:
00049
00053 AveragerPair(void);
00054
00059
00060
00061
00062
00066 AveragerPair(const AveragerPair&);
00067
00071 void add(const double x, const double y, const long n=1);
00072
00080 double ccc(void) const;
00081
00088 double correlation(void) const;
00089
00097 double covariance(void) const;
00098
00102 double mean_xy(void) const;
00103
00108 double msd(void) const;
00109
00113 long n(void) const;
00114
00118 void reset(void);
00119
00123 double sum_xy(void) const;
00124
00129 double sum_squared_deviation(void) const;
00130
00134 double sum_xy_centered(void) const;
00135
00139 const Averager& x_averager(void) const;
00140
00144 const Averager& y_averager(void) const;
00145
00149 const AveragerPair& operator=(const AveragerPair& a);
00150
00154 const AveragerPair& operator+=(const AveragerPair&);
00155
00156 private:
00157 Averager x_;
00158 Averager y_;
00159 double xy_;
00160
00161 };
00162
00168 template <class InputIterator1, class InputIterator2>
00169 void add(AveragerPair& ap, InputIterator1 first1, InputIterator1 last1,
00170 InputIterator2 first2)
00171 {
00172 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>));
00173 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>));
00174 utility::check_iterator_is_unweighted(first1);
00175 utility::check_iterator_is_unweighted(first2);
00176 for ( ; first1 != last1; ++first1, ++first2)
00177 ap.add(*first1, *first2);
00178 }
00179
00180
00181 }}}
00182
00183 #endif