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

Refs #245. A new structure to calculate distances between vectors that is based on iterators and traits patterns. Will replace the old inherited Distance structure. Support for iterators to weighted containers is not yet added

File size:
948 bytes

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  

10  namespace theplu { 

11  namespace yat { 

12  

13  namespace 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 1ap.correlation(); 

39  } 

40  

41  

42  }}} // of namespace statistics, yat, and theplu 

43  

44  #endif 

Note: See
TracBrowser
for help on using the repository browser.