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

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

A first suggestion for how to adress #250. Also removed contamination of namespace std (see #251).

• Property svn:eol-style set to `native`
• Property svn:keywords set to `Id`
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: pearson_vector_distance.h 898 2007-09-26 13:44:19Z markus \$
5
6#include "vector_distance.h"
7
8#include "AveragerPair.h"
9#include "AveragerPairWeighted.h"
10
11namespace theplu {
12namespace yat {
13
14namespace statistics {
15
16  ///
17  /// Provides a "label" for
18  /// the Pearson distance measure.
19  ///
20  struct pearson_vector_distance_tag
21    : public vector_distance_tag
22  {
23    typedef pearson_vector_distance_tag distance;
24  };
25
26
27  ///
28  /// implementation for distances between vectors
29  /// (containers with random access iterators) using a Pearson
30  /// distance measure and iterators to unweighted containers.
31  ///
32  template <class Iter>
33  double vector_distance(Iter beg1,Iter end1, Iter beg2,
34                         const pearson_vector_distance_tag& disttype,
35                         std::random_access_iterator_tag)
36  {
37    AveragerPair ap;
39    return 1-ap.correlation();
40  }
41
42  ///
43  /// implementation for distances between vectors
44  /// (containers with random access iterators) using a Pearson
45  /// distance measure and iterators to unweighted containers.
46  ///
47  template <class Iter>
48  double vector_distance(Iter beg1,Iter end1, Iter beg2,
49                         const pearson_vector_distance_tag& disttype,
50                         utility::weighted_random_access_iterator_tag)
51  {
52    AveragerPairWeighted ap;