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 916 2007-09-30 00:50:10Z peter $ |
---|

5 | |
---|

6 | #include "vector_distance.h" |
---|

7 | |
---|

8 | #include "AveragerPair.h" |
---|

9 | #include "AveragerPairWeighted.h" |
---|

10 | #include "yat/utility/IteratorTraits.h" |
---|

11 | |
---|

12 | namespace theplu { |
---|

13 | namespace yat { |
---|

14 | |
---|

15 | namespace 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; |
---|

39 | add(ap,beg1,end1,beg2); |
---|

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; |
---|

54 | add(ap,beg1,end1,beg2); |
---|

55 | return 1-ap.correlation(); |
---|

56 | } |
---|

57 | |
---|

58 | |
---|

59 | }}} // of namespace statistics, yat, and theplu |
---|

60 | |
---|

61 | #endif |
---|