gov.sandia.cognition.learning.function.distance
Class MinkowskiDistanceMetric

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.distance.MinkowskiDistanceMetric
All Implemented Interfaces:
DivergenceFunction<Vectorizable,Vectorizable>, Metric<Vectorizable>, Semimetric<Vectorizable>, CloneableSerializable, Serializable, 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
See Also:
Serialized Form

Field Summary
static double DEFAULT_POWER
          The default power is 2.0.
protected  double power
          The power that the distance is computed to.
 
Constructor Summary
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
 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
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_POWER

public static final double DEFAULT_POWER
The default power is 2.0.

See Also:
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.