Changeset 1115


Ignore:
Timestamp:
Feb 21, 2008, 8:20:59 PM (14 years ago)
Author:
Markus Ringnér
Message:

Fixes #254 and #295

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/concepts.doxygen

    r1113 r1115  
    3636\section Description
    3737
    38 \ref concept_distance is a concept ..
     38\ref concept_distance is a concept for classes implementing different
     39alternatives to calculate the distance between two points.
    3940
    4041\section Requirements
    4142
    42 Classes modelling the concept \ref concept_distance should implement ... 
     43Classes modelling the concept \ref concept_distance should implement
     44the following public function:
     45
     46\verbatim
     47template<typename Iter1, typename Iter2>
     48double  operator() (Iter1 beg1, Iter1 end1, Iter2 beg2) const
     49\endverbatim
     50
     51This function should calculate and return the distance between
     52elements of two ranges. The first range is given by [\a beg1, \a end1)
     53and the second range starts with \a beg2 and has the same length as
     54the first range. The function should support iterators of the category
     55std::forward_iterator. The function should provide both a fast
     56calculation for unweighted iterators and a calculation for weighted
     57iterators. The latter correspond to the case where elements in a range
     58have both a value and a weight. The selection between unweighted and
     59weighted implementations should utilize
     60theplu::yat::utility::weighted_iterator_tag. Moreover
     61theplu::yat::utility::weighted_if_any2 should be utilized to provide a
     62weighted implementation if any of the two ranges is weighted, and an
     63unweighted implementation when both ranges are unweighted.
     64
     65\section Implementations
    4366
    4467Examples of classes modelling the concept \ref concept_distance
     
    6083
    6184Classes modelling the concept \ref concept_neighbor_weighting should
    62 implement the following function:
     85implement the following public function:
    6386 
    6487\verbatim   
     
    78101class. The total vote for each class is stored in the vector \a prediction.
    79102
     103\section Implementations
     104
    80105Examples of classes modelling the concept \ref
    81106concept_neighbor_weighting include
  • trunk/yat/classifier/KNN.h

    r1112 r1115  
    4646  /// @brief Class for Nearest Neigbor Classification.
    4747  ///
    48   /// The template argument Distance should be a class implementing
     48  /// The template argument Distance should be a class modelling
    4949  /// the concept \ref concept_distance.
    50   /// The template argument NeigborWeighting should be a class implementing
     50  /// The template argument NeigborWeighting should be a class modelling
    5151  /// the concept \ref concept_neighbor_weighting.
    5252
  • trunk/yat/classifier/NCC.h

    r1112 r1115  
    5656  /// @brief Class for Nearest Centroid Classification.
    5757  ///
    58   /// The template argument Distance should be a class implementing
     58  /// The template argument Distance should be a class modelling
    5959  /// the concept \ref concept_distance.
    6060  ///
  • trunk/yat/statistics/EuclideanDistance.h

    r1093 r1115  
    3838  ///
    3939  /// @brief Calculates the Euclidean distance between two points
    40   /// stored in 1-dimensional containers. Implements the concept \ref
    41   /// concept_distance.
     40  /// given by elements of ranges.
     41  ///
     42  /// This class is modelling the concept \ref concept_distance.
    4243  ///
    4344  ///
     
    4546  {   
    4647    /**
    47        \brief Calculates the Euclidean distance between two ranges.
     48       \brief Calculates the Euclidean distance between elements of
     49       two ranges.
    4850   
    49        If both ranges are unweighted the distance is calculated as \f$
    50        \sqrt{\sum (x_i-y_i)^2 } \f$
     51       If elements of both ranges are unweighted the distance is
     52       calculated as \f$ \sqrt{\sum (x_i-y_i)^2 } \f$, where \f$ x_i
     53       \f$ and \f$ y_i \f$ are elements of the first and second range,
     54       respectively.
    5155
    52        Else distance is calculated as \f$ N \frac{\sum
    53        w_xw_y(x-y)^2}{\sum w_xw_y} \f$
     56       If elements of one or both of ranges have weights the distance
     57       is calculated as \f$ \sqrt{N \sum
     58       w_{x,i}w_{y,i}(x_i-y_i)^2/\sum w_{x,i}w_{y,i}} \f$, where \f$ N
     59       \f$ is the number of elements in the two ranges and \f$ w_x \f$
     60       and \f$ w_y \f$ are weights for the elements of the first and
     61       the second range, respectively. If the elements of one of the
     62       two ranges are unweighted, the weights for these elements are
     63       set to unity.
    5464    */
    5565    template <typename Iter1, typename Iter2>
  • trunk/yat/statistics/PearsonDistance.h

    r1092 r1115  
    3535
    3636  ///
    37   /// @brief Calculates the %Pearson correlation distance between two points stored in 1-dimensional containers. Implements the concept \ref concept_distance.
     37  /// @brief Calculates the %Pearson correlation distance between two points given by elements of ranges.
    3838  ///
     39  /// This class is modelling the concept \ref concept_distance.
    3940  ///
    4041  struct PearsonDistance
    4142  {
    42     ///
    43     /// @brief Calculates the %Pearson correlation distance between two ranges.
    44     ///
     43    /**
     44       \brief Calculates the %Pearson correlation distance between
     45       elements of two ranges.
     46   
     47       If elements of both ranges are unweighted the distance is
     48       calculated as \f$ 1-\mbox{C}(x,y) \f$, where \f$ x \f$ and \f$
     49       y \f$ are the two points and C is the %Pearson correlation.
     50
     51       If elements of one or both of ranges have weights the distance
     52       is calculated as \f$ 1-[\sum w_{x,i}w_{y,i}(x_i-y_i)^2/(\sum
     53       w_{x,i}w_{y,i}(x_i-m_x)^2\sum w_{x,i}w_{y,i}(y_i-m_y)^2)] \f$,
     54       where and \f$ w_x \f$ and \f$ w_y \f$ are weights for the
     55       elements of the first and the second range, respectively, and
     56       \f$ m_x=\sum w_{x,i}w_{y,i}x_i/\sum w_{x,i}w_{y,i} \f$ and
     57       correspondingly for \f$ m_y \f$.  If the elements of one of the
     58       two ranges are unweighted, the weights for these elements are
     59       set to unity.
     60    */   
    4561    template <typename Iter1, typename Iter2>
    4662    double operator()
  • trunk/yat/utility/iterator_traits.h

    r1092 r1115  
    3737  /**
    3838    Struct to be used to make compile-time decision that Iterator is
    39     weighted. Some algorithms come in also in a weighted version in
     39    weighted. Some algorithms come also in a weighted version and
    4040    this tag could be used to decide on using them (rather than
    41     unweighted cousin).
     41    the corresponding unweighted algorithm).
    4242   */
    4343  struct weighted_iterator_tag {};
     
    109109
    110110  /**
    111      \brief traits to make unweighted iterator work in as a weighted
     111     \brief traits to make unweighted iterator work as in a weighted
    112112
    113113     This class must be implemented for every iterator that can be weighted.
Note: See TracChangeset for help on using the changeset viewer.