smile.math.distance
Class SparseManhattanDistance
- java.lang.Object
-
- smile.math.distance.SparseManhattanDistance
-
- All Implemented Interfaces:
- java.io.Serializable, Distance<SparseArray>, Metric<SparseArray>
public class SparseManhattanDistance extends java.lang.Object implements Metric<SparseArray>, java.io.Serializable
Manhattan distance, also known as L1 distance or L1 norm, is the sum of the (absolute) differences of their coordinates. Use getInstance() to get the standard unweighted Manhattan distance. Or create an instance with a specified weight vector. For float or double arrays, missing values (i.e. NaN) are also handled. Also support sparse arrays of which zeros are excluded to save space.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SparseManhattanDistance()Constructor.SparseManhattanDistance(double[] weight)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubled(SparseArray x, SparseArray y)Returns the distance measure between two objects.java.lang.StringtoString()
-
-
-
Constructor Detail
-
SparseManhattanDistance
public SparseManhattanDistance()
Constructor.
-
SparseManhattanDistance
public SparseManhattanDistance(double[] weight)
Constructor.- Parameters:
weight- the weight vector.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
d
public double d(SparseArray x, SparseArray y)
Description copied from interface:DistanceReturns the distance measure between two objects.- Specified by:
din interfaceDistance<SparseArray>
-
-
DataMelt 3.0 © DataMelt by jWork.ORG