source: trunk/yat/statistics/pearson_vector_distance.h @ 895

Last change on this file since 895 was 895, checked in by Peter, 14 years ago

Another try, hm...

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • 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 895 2007-09-25 20:39:14Z peter $
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;
37    add(ap,beg1,end1,beg2);
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;
52    add(ap,beg1,end1,beg2);
53    return 1-ap.correlation();
54  }
55
56 
57}}} // of namespace statistics, yat, and theplu
58   
59#endif
Note: See TracBrowser for help on using the repository browser.