C# Class SharpNeat.DistanceMetrics.EuclideanDistanceMetric

Euclidean distance metric. The Euclidean distance is given by sqrt(sum(delta^2)) Where [delta] is the absolute position difference in a given dimension (on a given axis).
Inheritance: IDistanceMetric
Show file Open project: colgreen/sharpneat

Public Methods

Method Description
CalculateCentroid ( IList coordList ) : CoordinateVector

Calculates the centroid for the given set of points. For the Euclidean distance metric the centroid is given by calculating the componentwise mean over the set of points.

CalculateCentroidParallel ( IList coordList ) : CoordinateVector

Parallelized version of CalculateCentroid().

MeasureDistance ( CoordinateVector p1, CoordinateVector p2, double threshold ) : bool

Tests if the distance between two positions is less than some threshold. A simple way of implementing this method would be to calculate the distance between the two coordinates and test if it is less than the threshold. However, that approach requires that all of the elements in both CoordinateVectors be fully compared. We can improve performance in the general case by testing if the threshold has been passed after each vector element comparison thus allowing an early exit from the method for many calls. Further to this, we can begin comparing from the ends of the vectors where differences are most likely to occur.

MeasureDistance ( CoordinateVector p1, CoordinateVector p2 ) : double

Measures the distance between two positions.

Method Details

CalculateCentroid() public method

Calculates the centroid for the given set of points. For the Euclidean distance metric the centroid is given by calculating the componentwise mean over the set of points.
public CalculateCentroid ( IList coordList ) : CoordinateVector
coordList IList
return SharpNeat.Core.CoordinateVector

CalculateCentroidParallel() public method

Parallelized version of CalculateCentroid().
public CalculateCentroidParallel ( IList coordList ) : CoordinateVector
coordList IList
return SharpNeat.Core.CoordinateVector

MeasureDistance() public method

Tests if the distance between two positions is less than some threshold. A simple way of implementing this method would be to calculate the distance between the two coordinates and test if it is less than the threshold. However, that approach requires that all of the elements in both CoordinateVectors be fully compared. We can improve performance in the general case by testing if the threshold has been passed after each vector element comparison thus allowing an early exit from the method for many calls. Further to this, we can begin comparing from the ends of the vectors where differences are most likely to occur.
public MeasureDistance ( CoordinateVector p1, CoordinateVector p2, double threshold ) : bool
p1 SharpNeat.Core.CoordinateVector
p2 SharpNeat.Core.CoordinateVector
threshold double
return bool

MeasureDistance() public method

Measures the distance between two positions.
public MeasureDistance ( CoordinateVector p1, CoordinateVector p2 ) : double
p1 SharpNeat.Core.CoordinateVector
p2 SharpNeat.Core.CoordinateVector
return double