Changeset 890 for trunk/yat/statistics
- Timestamp:
- Sep 25, 2007, 11:35:25 AM (16 years ago)
- Location:
- trunk/yat/statistics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/statistics/AveragerPairWeighted.cc
r865 r890 96 96 double AveragerPairWeighted::msd(void) const 97 97 { 98 return ( x_.sum_wxx()+y_.sum_wxx()-2*wxy_)/w_;98 return sum_squared_deviation()/w_; 99 99 } 100 100 … … 104 104 x_.reset(); y_.reset(); wxy_=0; w_=0; 105 105 } 106 107 double AveragerPairWeighted::sum_squared_deviation(void) const 108 { 109 return x_.sum_wxx()+y_.sum_wxx()-2*wxy_; 110 } 111 106 112 107 113 double AveragerPairWeighted::sum_w(void) const -
trunk/yat/statistics/AveragerPairWeighted.h
r865 r890 133 133 134 134 /// 135 /// @return Sum of weighted squared deviation between x and y \f$ 136 /// \sum (w_xx-wyy)^2 \f$ 137 /// 138 double sum_squared_deviation(void) const; 139 140 /// 135 141 /// @return \f$ \sum w_xw_y \f$ 136 142 /// … … 169 175 170 176 }; 177 178 /** 179 \brief adding a ranges of values to AveragerPairWeighted \a ap 180 */ 181 template <class Iter1, class Iter2> 182 void add(AveragerPairWeighted& ap, Iter1 first1, Iter1 last1, Iter2 first2) 183 { 184 for ( ; first1 != last1; ++first1, ++first2) 185 ap.add(first1.data(), first2.data(),first1.weight(),first2.weight()); 186 } 187 188 189 171 190 172 191 template <typename T1,typename T2,typename T3,typename T4> -
trunk/yat/statistics/euclidean_vector_distance.h
r889 r890 5 5 6 6 #include "AveragerPair.h" 7 #include "AveragerPairWeighted.h" 7 8 #include "vector_distance.h" 8 9 … … 40 41 } 41 42 43 44 /// 45 /// implementation for distances between vectors 46 /// (containers with random access iterators) using a Euclidean 47 /// distance measure and iterators to weighted containers. 48 /// 49 template <class Iter> 50 double vector_distance(Iter beg1,Iter end1, Iter beg2, 51 const euclidean_vector_distance_tag& disttype, 52 std::weighted_random_access_iterator_tag) 53 { 54 AveragerPairWeighted ap; 55 add(ap,beg1,end1,beg2); 56 return sqrt(ap.sum_squared_deviation()); 57 } 58 42 59 43 60 }}} // of namespace statistics, yat, and theplu -
trunk/yat/statistics/pearson_vector_distance.h
r889 r890 39 39 } 40 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 41 56 42 57 }}} // of namespace statistics, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.