@Priority(value=200) @Alias(value={"lp","minkowski","p","de.lmu.ifi.dbs.elki.distance.distancefunction.LPNormDistanceFunction"}) public class LPNormDistanceFunction extends java.lang.Object implements SpatialPrimitiveDistanceFunction<NumberVector>, NumberVectorDistanceFunction<NumberVector>, Norm<NumberVector>
NumberVector
s.
The Lp distance is defined as: \[ L_p(\vec{x},\vec{y}) := \left(\sum\nolimits_i (x_i-y_i)\right)^{1/p} \]
For p >= 1 this is a metric. For p=1, this yields the well known
ManhattanDistanceFunction
, for p = 2 the standard
EuclideanDistanceFunction
.
Modifier and Type | Class and Description |
---|---|
static class |
LPNormDistanceFunction.Parameterizer
Parameterization class.
|
Modifier and Type | Field and Description |
---|---|
protected double |
invp
p parameter and its inverse.
|
protected double |
p
p parameter and its inverse.
|
Constructor and Description |
---|
LPNormDistanceFunction(double p)
Constructor, internal version.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(NumberVector v1,
NumberVector v2)
Computes the distance between two given DatabaseObjects according to this
distance function.
|
boolean |
equals(java.lang.Object obj) |
SimpleTypeInformation<? super NumberVector> |
getInputTypeRestriction()
Get the input data type of the function.
|
double |
getP()
Get the functions p parameter.
|
int |
hashCode() |
boolean |
isMetric()
Is this distance function metric (satisfy the triangle inequality)
|
double |
minDist(SpatialComparable mbr1,
SpatialComparable mbr2)
Computes the distance between the two given MBRs according to this distance
function.
|
double |
norm(NumberVector v)
Compute the norm of object obj.
|
private double |
preDistance(NumberVector v1,
NumberVector v2,
int start,
int end)
Compute unscaled distance in a range of dimensions.
|
private double |
preDistanceMBR(SpatialComparable mbr1,
SpatialComparable mbr2,
int start,
int end)
Compute unscaled distance in a range of dimensions.
|
private double |
preDistanceVM(NumberVector v,
SpatialComparable mbr,
int start,
int end)
Compute unscaled distance in a range of dimensions.
|
private double |
preNorm(NumberVector v,
int start,
int end)
Compute unscaled norm in a range of dimensions.
|
private double |
preNormMBR(SpatialComparable mbr,
int start,
int end)
Compute unscaled norm in a range of dimensions.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
instantiate
isSquared, isSymmetric
protected double p
protected double invp
public LPNormDistanceFunction(double p)
p
- Parameter pprivate double preDistance(NumberVector v1, NumberVector v2, int start, int end)
v1
- First objectv2
- Second objectstart
- First dimensionend
- Exclusive last dimensionprivate double preDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)
v
- First vectormbr
- Second MBRstart
- First dimensionend
- Exclusive last dimensionprivate double preDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)
mbr1
- First MBRmbr2
- Second MBRstart
- First dimensionend
- Exclusive last dimensionprivate double preNorm(NumberVector v, int start, int end)
v
- Data objectstart
- First dimensionend
- Exclusive last dimensionprivate double preNormMBR(SpatialComparable mbr, int start, int end)
mbr
- Data objectstart
- First dimensionend
- Exclusive last dimensionpublic double distance(NumberVector v1, NumberVector v2)
PrimitiveDistanceFunction
distance
in interface NumberVectorDistanceFunction<NumberVector>
distance
in interface PrimitiveDistanceFunction<NumberVector>
v1
- first DatabaseObjectv2
- second DatabaseObjectpublic double norm(NumberVector v)
Norm
norm
in interface Norm<NumberVector>
v
- Objectpublic double minDist(SpatialComparable mbr1, SpatialComparable mbr2)
SpatialPrimitiveDistanceFunction
minDist
in interface SpatialPrimitiveDistanceFunction<NumberVector>
mbr1
- the first MBR objectmbr2
- the second MBR objectpublic boolean isMetric()
DistanceFunction
isMetric
in interface DistanceFunction<NumberVector>
true
when metric.public java.lang.String toString()
toString
in class java.lang.Object
public double getP()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public SimpleTypeInformation<? super NumberVector> getInputTypeRestriction()
DistanceFunction
getInputTypeRestriction
in interface DistanceFunction<NumberVector>
getInputTypeRestriction
in interface PrimitiveDistanceFunction<NumberVector>
Copyright © 2019 ELKI Development Team. License information.