# source:trunk/yat/statistics/pearson_vector_distance.h@890

Last change on this file since 890 was 890, checked in by Markus Ringnér, 15 years ago

Refs #245 #246 #247

File size: 1.4 KB
Line
1#ifndef theplu_yat_statistics_pearson_vector_distance_h
2#define theplu_yat_statistics_pearson_vector_distance_h
3
4// \$Id\$
5
6#include "vector_distance.h"
7
8#include "AveragerPair.h"
9
10namespace theplu {
11namespace yat {
12
13namespace statistics {
14
15  ///
16  /// Provides a "label" for
17  /// the Pearson distance measure.
18  ///
19  struct pearson_vector_distance_tag
20    : public vector_distance_tag
21  {
22    typedef pearson_vector_distance_tag distance;
23  };
24
25
26  ///
27  /// implementation for distances between vectors
28  /// (containers with random access iterators) using a Pearson
29  /// distance measure and iterators to unweighted containers.
30  ///
31  template <class Iter>
32  double vector_distance(Iter beg1,Iter end1, Iter beg2,
33                         const pearson_vector_distance_tag& disttype,
34                         std::random_access_iterator_tag)
35  {
36    AveragerPair ap;
38    return 1-ap.correlation();
39  }
40
41  ///
42  /// implementation for distances between vectors
43  /// (containers with random access iterators) using a Pearson
44  /// distance measure and iterators to unweighted containers.
45  ///
46  template <class Iter>
47  double vector_distance(Iter beg1,Iter end1, Iter beg2,
48                         const pearson_vector_distance_tag& disttype,
49                         std::weighted_random_access_iterator_tag)
50  {
51    AveragerPairWeighted ap;