Click or drag to resize

DistanceCityBlockDistance Method

Compute the city-block (Manhattan) distance between two data sets (1 norm).

Namespace:  CenterSpace.NMath.Core
Assembly:  NMath (in NMath.dll) Version: 7.4
Syntax
public static double CityBlockDistance(
	DoubleVector data1,
	DoubleVector data2
)

Parameters

data1
Type: CenterSpace.NMath.CoreDoubleVector
The first data set.
data2
Type: CenterSpace.NMath.CoreDoubleVector
The second data set.

Return Value

Type: Double
The distance between data1 and data2.
Exceptions
ExceptionCondition
MismatchedSizeException Thrown if the given data sets do not have equal lengths.
Remarks
This distance is computed as:
distance( x, y ) = sum ( | xi - yi | )
In most cases, the city-block distance measure yields results similar to the simple Euclidean distance. Note, however, that the effect of outliers is dampened, since they are not squared.
Missing values are allowed. Pairs of elements are excluded from the distance measure when their comparison returns NaN. If all pairs are excluded, NaN is returned for the distance measure.
See Also