# Changeset 1115

Ignore:
Timestamp:
Feb 21, 2008, 8:20:59 PM (15 years ago)
Message:

Fixes #254 and #295

Location:
trunk
Files:
6 edited

Unmodified
Added
Removed
• ## trunk/doc/concepts.doxygen

 r1113 \section Description \ref concept_distance is a concept .. \ref concept_distance is a concept for classes implementing different alternatives to calculate the distance between two points. \section Requirements Classes modelling the concept \ref concept_distance should implement ... Classes modelling the concept \ref concept_distance should implement the following public function: \verbatim template double  operator() (Iter1 beg1, Iter1 end1, Iter2 beg2) const \endverbatim This function should calculate and return the distance between elements of two ranges. The first range is given by [\a beg1, \a end1) and the second range starts with \a beg2 and has the same length as the first range. The function should support iterators of the category std::forward_iterator. The function should provide both a fast calculation for unweighted iterators and a calculation for weighted iterators. The latter correspond to the case where elements in a range have both a value and a weight. The selection between unweighted and weighted implementations should utilize theplu::yat::utility::weighted_iterator_tag. Moreover theplu::yat::utility::weighted_if_any2 should be utilized to provide a weighted implementation if any of the two ranges is weighted, and an unweighted implementation when both ranges are unweighted. \section Implementations Examples of classes modelling the concept \ref concept_distance Classes modelling the concept \ref concept_neighbor_weighting should implement the following function: implement the following public function: \verbatim class. The total vote for each class is stored in the vector \a prediction. \section Implementations Examples of classes modelling the concept \ref concept_neighbor_weighting include
• ## trunk/yat/classifier/KNN.h

 r1112 /// @brief Class for Nearest Neigbor Classification. /// /// The template argument Distance should be a class implementing /// The template argument Distance should be a class modelling /// the concept \ref concept_distance. /// The template argument NeigborWeighting should be a class implementing /// The template argument NeigborWeighting should be a class modelling /// the concept \ref concept_neighbor_weighting.
• ## trunk/yat/classifier/NCC.h

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

 r1093 /// /// @brief Calculates the Euclidean distance between two points /// stored in 1-dimensional containers. Implements the concept \ref /// concept_distance. /// given by elements of ranges. /// /// This class is modelling the concept \ref concept_distance. /// /// { /** \brief Calculates the Euclidean distance between two ranges. \brief Calculates the Euclidean distance between elements of two ranges. If both ranges are unweighted the distance is calculated as \f$\sqrt{\sum (x_i-y_i)^2 } \f$ If elements of both ranges are unweighted the distance is calculated as \f$\sqrt{\sum (x_i-y_i)^2 } \f$, where \f$x_i \f$ and \f$y_i \f$ are elements of the first and second range, respectively. Else distance is calculated as \f$N \frac{\sum w_xw_y(x-y)^2}{\sum w_xw_y} \f$ If elements of one or both of ranges have weights the distance is calculated as \f$\sqrt{N \sum w_{x,i}w_{y,i}(x_i-y_i)^2/\sum w_{x,i}w_{y,i}} \f$, where \f$N \f$ is the number of elements in the two ranges and \f$w_x \f$ and \f$w_y \f$ are weights for the elements of the first and the second range, respectively. If the elements of one of the two ranges are unweighted, the weights for these elements are set to unity. */ template
• ## trunk/yat/statistics/PearsonDistance.h

 r1092 /// /// @brief Calculates the %Pearson correlation distance between two points stored in 1-dimensional containers. Implements the concept \ref concept_distance. /// @brief Calculates the %Pearson correlation distance between two points given by elements of ranges. /// /// This class is modelling the concept \ref concept_distance. /// struct PearsonDistance { /// /// @brief Calculates the %Pearson correlation distance between two ranges. /// /** \brief Calculates the %Pearson correlation distance between elements of two ranges. If elements of both ranges are unweighted the distance is calculated as \f$1-\mbox{C}(x,y) \f$, where \f$x \f$ and \f$y \f$ are the two points and C is the %Pearson correlation. If elements of one or both of ranges have weights the distance is calculated as \f$1-[\sum w_{x,i}w_{y,i}(x_i-y_i)^2/(\sum w_{x,i}w_{y,i}(x_i-m_x)^2\sum w_{x,i}w_{y,i}(y_i-m_y)^2)] \f$, where and \f$w_x \f$ and \f$w_y \f$ are weights for the elements of the first and the second range, respectively, and \f$m_x=\sum w_{x,i}w_{y,i}x_i/\sum w_{x,i}w_{y,i} \f$ and correspondingly for \f$m_y \f$.  If the elements of one of the two ranges are unweighted, the weights for these elements are set to unity. */ template double operator()
• ## trunk/yat/utility/iterator_traits.h

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