yat  0.21pre
Public Member Functions | Friends | List of all members
theplu::yat::statistics::EuclideanDistance Class Reference

Calculates the Euclidean distance between elements of two ranges. More...

#include <yat/statistics/EuclideanDistance.h>

Inheritance diagram for theplu::yat::statistics::EuclideanDistance:
theplu::yat::statistics::Distance< EuclideanDistance >

Public Member Functions

double operator() (Iterator1 beg1, Iterator1 end1, Iterator2 beg2) const
 

Friends

class Distance< EuclideanDistance >
 

Detailed Description

Calculates the Euclidean distance between elements of two ranges.

If elements of both ranges are unweighted the distance is calculated as $ \sqrt{\sum (x_i-y_i)^2 } $, where $ x_i $ and $ y_i $ are elements of the first and second range, respectively.

If elements of one or both of ranges have weights the distance is calculated as $ \sqrt{N \sum w_{x,i}w_{y,i}(x_i-y_i)^2/\sum w_{x,i}w_{y,i}} $, where $ N $ is the number of elements in the two ranges and $ w_x $ and $ w_y $ 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.

Member Function Documentation

◆ operator()()

double theplu::yat::statistics::Distance< EuclideanDistance >::operator() ( Iterator1  beg1,
Iterator1  end1,
Iterator2  beg2 
) const
inlineinherited

Function determines ranges are weighted or unweighted and calls the appropriate function in Derived.

If both ranges are unweighted function

Derived::distance(beg1, end1, beg2, utility::unweighted_iterator_tag)

and otherwise function

Derived::distance(beg1, end1, beg2, utility::weighted_iterator_tag)

is called

Type Requirements:


The documentation for this class was generated from the following file:

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14