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

Last change on this file since 909 was 909, checked in by Peter, 15 years ago

using weighted_iterator_traits, closes #151

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