Changeset 1050 for trunk/yat/statistics
- Timestamp:
- Feb 7, 2008, 7:47:34 PM (16 years ago)
- Location:
- trunk/yat/statistics
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/statistics/Makefile.am
r1031 r1050 40 40 include_statistics_HEADERS = AUC.h Averager.h AveragerPair.h \ 41 41 AveragerWeighted.h AveragerPairWeighted.h \ 42 distance.heuclidean_distance.h Fisher.h \42 euclidean_distance.h Fisher.h \ 43 43 FoldChange.h Histogram.h \ 44 44 KolmogorovSmirnov.h \ -
trunk/yat/statistics/euclidean_distance.h
r1031 r1050 6 6 /* 7 7 Copyright (C) 2007 Peter Johansson, Markus Ringnér 8 Copyright (C) 2008 Peter Johansson 8 9 9 10 This file is part of the yat library, http://trac.thep.lu.se/yat … … 27 28 #include "AveragerPair.h" 28 29 #include "AveragerPairWeighted.h" 29 #include "distance.h"30 30 #include "yat/utility/iterator_traits.h" 31 31 … … 34 34 namespace theplu { 35 35 namespace yat { 36 37 36 namespace statistics { 38 37 39 /// 40 /// Provides a "label" for 41 /// the Euclidean distance measure. 42 /// 43 struct euclidean_distance_tag 44 : public distance_tag 38 struct EuclideanDistance 45 39 { 46 /// \brief tag for euclidean distance 47 typedef euclidean_distance_tag distance; 40 template <typename Iter1, typename Iter2> 41 double operator() 42 (Iter1 beg1,Iter1 end1, Iter2 beg2) const 43 { 44 return this->distance(beg1, end1, beg2, 45 typename utility::weighted_if_any2<Iter1,Iter2>::type()); 46 } 47 48 private: 49 template <typename Iter1, typename Iter2> 50 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2, 51 utility::unweighted_type) const 52 { 53 AveragerPair ap; 54 add(ap,beg1,end1,beg2); 55 return sqrt(ap.sum_squared_deviation()); 56 } 57 58 template <typename Iter1, typename Iter2> 59 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2, 60 utility::weighted_type) const 61 { 62 AveragerPairWeighted ap; 63 add(ap,beg1,end1,beg2); 64 return sqrt(std::distance(beg1,end1)*ap.msd()); 65 } 66 48 67 }; 49 68 50 51 ///52 /// implementation for distances between vectors53 /// (containers with random access iterators) using a Euclidean54 /// distance measure and iterators to unweighted containers.55 ///56 template <typename Iter1, typename Iter2>57 double distance(Iter1 beg1,Iter1 end1, Iter2 beg2,58 const euclidean_distance_tag& disttype,59 utility::unweighted_type)60 {61 AveragerPair ap;62 add(ap,beg1,end1,beg2);63 return sqrt(ap.sum_squared_deviation());64 }65 66 67 ///68 /// implementation for distances between vectors69 /// (containers with random access iterators) using a Euclidean70 /// distance measure and iterators to weighted containers.71 ///72 template <typename Iter1, typename Iter2>73 double distance(Iter1 beg1, Iter1 end1, Iter2 beg2,74 const euclidean_distance_tag& disttype,75 utility::weighted_type)76 {77 AveragerPairWeighted ap;78 add(ap,beg1,end1,beg2);79 return sqrt(std::distance(beg1,end1)*ap.msd());80 }81 82 83 69 }}} // of namespace statistics, yat, and theplu 84 70 -
trunk/yat/statistics/pearson_distance.h
r1031 r1050 6 6 /* 7 7 Copyright (C) 2007 Peter Johansson, Markus Ringnér 8 Copyright (C) 2008 Peter Johansson 8 9 9 10 This file is part of the yat library, http://trac.thep.lu.se/yat … … 25 26 */ 26 27 27 #include "distance.h"28 29 28 #include "AveragerPair.h" 30 29 #include "AveragerPairWeighted.h" … … 33 32 namespace theplu { 34 33 namespace yat { 35 36 34 namespace statistics { 37 35 38 /// 39 /// Provides a "label" for 40 /// the Pearson distance measure. 41 /// 42 struct pearson_distance_tag 43 : public distance_tag 36 struct PearsonDistance 44 37 { 45 /// \brief tag for pearson distance 46 typedef pearson_distance_tag distance; 38 template <typename Iter1, typename Iter2> 39 double operator() 40 (Iter1 beg1,Iter1 end1, Iter2 beg2) const 41 { 42 return this->distance(beg1, end1, beg2, 43 typename utility::weighted_if_any2<Iter1,Iter2>::type()); 44 } 45 46 private: 47 template <typename Iter1, typename Iter2> 48 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2, 49 utility::unweighted_type) const 50 { 51 AveragerPairWeighted ap; 52 add(ap,beg1,end1,beg2); 53 return 1-ap.correlation(); 54 } 55 56 template <typename Iter1, typename Iter2> 57 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2, 58 utility::weighted_type) const 59 { 60 AveragerPairWeighted ap; 61 add(ap,beg1,end1,beg2); 62 return 1-ap.correlation(); 63 } 64 47 65 }; 48 66 49 50 ///51 /// implementation for distances between vectors52 /// (containers with random access iterators) using a Pearson53 /// distance measure and iterators to unweighted containers.54 ///55 template <class Iter>56 double distance(Iter beg1,Iter end1, Iter beg2,57 const pearson_distance_tag& disttype,58 utility::unweighted_type)59 {60 AveragerPair ap;61 add(ap,beg1,end1,beg2);62 return 1-ap.correlation();63 }64 65 ///66 /// implementation for distances between vectors67 /// (containers with random access iterators) using a Pearson68 /// distance measure and iterators to unweighted containers.69 ///70 template <class Iter>71 double distance(Iter beg1,Iter end1, Iter beg2,72 const pearson_distance_tag& disttype,73 utility::weighted_type)74 {75 AveragerPairWeighted ap;76 add(ap,beg1,end1,beg2);77 return 1-ap.correlation();78 }79 80 81 67 }}} // of namespace statistics, yat, and theplu 82 68
Note: See TracChangeset
for help on using the changeset viewer.