smile.math.distance
Class SparseMinkowskiDistance
- java.lang.Object
-
- smile.math.distance.SparseMinkowskiDistance
-
- All Implemented Interfaces:
- java.io.Serializable, Distance<SparseArray>, Metric<SparseArray>
public class SparseMinkowskiDistance extends java.lang.Object implements Metric<SparseArray>, java.io.Serializable
Minkowski distance of order p or Lp-norm, is a generalization of Euclidean distance that is actually L2-norm. You may also provide 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 SparseMinkowskiDistance(int p)Constructor.SparseMinkowskiDistance(int p, 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
-
SparseMinkowskiDistance
public SparseMinkowskiDistance(int p)
Constructor.
-
SparseMinkowskiDistance
public SparseMinkowskiDistance(int p, 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