gov.sandia.cognition.learning.function.distance

## Class MinkowskiDistanceMetric

• All Implemented Interfaces:
DivergenceFunction<Vectorizable,Vectorizable>, Metric<Vectorizable>, Semimetric<Vectorizable>, CloneableSerializable, java.io.Serializable, java.lang.Cloneable

```@PublicationReference(title="Minkowski Distance",
author="Wikipedia",
year=2011,
type=WebPage,
url="http://en.wikipedia.org/wiki/Minkowski_distance")
public class MinkowskiDistanceMetric
extends AbstractCloneableSerializable
implements Metric<Vectorizable>```
An implementation of the Minkowski distance metric. The metric is a generalization of the 2-norm (Euclidean) and 1-norm (Manhattan) distances to an arbitrary p-norm (p > 0). It is defined as: d(x, y) = (||x - y||_p)^(1/p) To support a power of infinity, see `ChebyshevDistanceMetric`.
Since:
3.3.3
Author:
Justin Basilico
Serialized Form
• ### Field Summary

Fields
Modifier and Type Field and Description
`static double` `DEFAULT_POWER`
The default power is 2.0.
`protected double` `power`
The power that the distance is computed to.
• ### Constructor Summary

Constructors
Constructor and Description
`MinkowskiDistanceMetric()`
Creates a new `MinkowskiDistanceMetric` with the default power of 2.0.
`MinkowskiDistanceMetric(double power)`
Creates a new `MinkowskiDistanceMetric` with the given power.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`double` ```evaluate(Vectorizable first, Vectorizable second)```
Evaluates the divergence between the two given objects.
`double` `getPower()`
Gets the power used for the distance.
`void` `setPower(double power)`
Sets the power used for the distance.
• ### Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable

`clone`
• ### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### DEFAULT_POWER

`public static final double DEFAULT_POWER`
The default power is 2.0.
Constant Field Values
• #### power

`protected double power`
The power that the distance is computed to.
• ### Constructor Detail

• #### MinkowskiDistanceMetric

`public MinkowskiDistanceMetric()`
Creates a new `MinkowskiDistanceMetric` with the default power of 2.0.
• #### MinkowskiDistanceMetric

`public MinkowskiDistanceMetric(double power)`
Creates a new `MinkowskiDistanceMetric` with the given power.
Parameters:
`power` - The power for the distance metric. Must be positive.
• ### Method Detail

• #### evaluate

```public double evaluate(Vectorizable first,
Vectorizable second)```
Description copied from interface: `DivergenceFunction`
Evaluates the divergence between the two given objects.
Specified by:
`evaluate` in interface `DivergenceFunction<Vectorizable,Vectorizable>`
Parameters:
`first` - The first object.
`second` - The second object.
Returns:
The divergence between the objects.
• #### getPower

`public double getPower()`
Gets the power used for the distance.
Returns:
The power used for the distance. Must be positive.
• #### setPower

`public void setPower(double power)`
Sets the power used for the distance.
Parameters:
`power` - The power used for the distance. Must be positive.