Changeset 890 for trunk/yat/statistics


Ignore:
Timestamp:
Sep 25, 2007, 11:35:25 AM (14 years ago)
Author:
Markus Ringnér
Message:

Refs #245 #246 #247

Location:
trunk/yat/statistics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/AveragerPairWeighted.cc

    r865 r890  
    9696  double AveragerPairWeighted::msd(void) const
    9797  {
    98     return ( x_.sum_wxx()+y_.sum_wxx()-2*wxy_)/w_;
     98    return sum_squared_deviation()/w_;
    9999  }
    100100
     
    104104    x_.reset(); y_.reset(); wxy_=0; w_=0;
    105105  }
     106
     107  double AveragerPairWeighted::sum_squared_deviation(void) const
     108  {
     109    return x_.sum_wxx()+y_.sum_wxx()-2*wxy_;
     110  }
     111 
    106112
    107113  double AveragerPairWeighted::sum_w(void) const
  • trunk/yat/statistics/AveragerPairWeighted.h

    r865 r890  
    133133
    134134    ///
     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    ///
    135141    /// @return \f$ \sum w_xw_y \f$
    136142    ///
     
    169175
    170176  };
     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
    171190
    172191  template <typename T1,typename T2,typename T3,typename T4>
  • trunk/yat/statistics/euclidean_vector_distance.h

    r889 r890  
    55
    66#include "AveragerPair.h"
     7#include "AveragerPairWeighted.h"
    78#include "vector_distance.h"
    89
     
    4041  }
    4142 
     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
    4259 
    4360}}} // of namespace statistics, yat, and theplu
  • trunk/yat/statistics/pearson_vector_distance.h

    r889 r890  
    3939  }
    4040 
     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
    4156 
    4257}}} // of namespace statistics, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.