yat  0.14.5pre
EuclideanDistance.h
1 #ifndef theplu_yat_statistics_euclidean_distance_h
2 #define theplu_yat_statistics_euclidean_distance_h
3 
4 // $Id: EuclideanDistance.h 3550 2017-01-03 05:41:02Z peter $
5 
6 /*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
8  Copyright (C) 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 #include "AveragerPair.h"
27 #include "AveragerPairWeighted.h"
28 #include "Distance.h"
29 
30 #include <cmath>
31 
32 namespace theplu {
33 namespace yat {
34 namespace statistics {
35 
54  class EuclideanDistance : public Distance<EuclideanDistance>
55  {
56  private:
57  friend class Distance<EuclideanDistance>;
58 
59  template <typename Iter1, typename Iter2>
60  double distance (Iter1 beg1,Iter1 end1, Iter2 beg2,
62  {
63  AveragerPair ap;
64  add(ap,beg1,end1,beg2);
65  return sqrt(ap.sum_squared_deviation());
66  }
67 
68  template <typename Iter1, typename Iter2>
69  double distance (Iter1 beg1,Iter1 end1, Iter2 beg2,
71  {
73  add(ap,beg1,end1,beg2);
74  return sqrt(std::distance(beg1,end1)*ap.msd());
75  }
76 
77  };
78 
79 }}} // of namespace statistics, yat, and theplu
80 
81 #endif
Class for taking care of mean and covariance of two variables in a weighted manner.
Definition: AveragerPairWeighted.h:56
Definition: iterator_traits.h:47
A convenience class to implement Distance.
Definition: Distance.h:65
double sum_squared_deviation(void) const
Class for taking care of mean and covariance of two variables.
Definition: AveragerPair.h:47
Definition: iterator_traits.h:55
void add(T &o, ForwardIterator first, ForwardIterator last, const classifier::Target &target)
Definition: utility.h:304
Calculates the Euclidean distance between elements of two ranges.
Definition: EuclideanDistance.h:54

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