|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unibi.techfak.jpredictor.clustering.RelationMeasure
de.unibi.techfak.jpredictor.clustering.VectorRelationMeasure
de.unibi.techfak.jpredictor.clustering.MinkowskiDistance
public class MinkowskiDistance
Calculates the distance between two vectors. The formula behind is: (sum_{i=1}^{n}{|x_i-y_i|^p})^(1/p). Special distances are defined for p=1 (Manhatten Distance Measure) and p=2 (Euclidian Distance Measure).
This class computes the distance for only two vectors. If more than two arrays were added the latest added are used for computation.
| Field Summary | |
|---|---|
(package private) double |
p
Defines the exponent for the minkowski distance. |
| Fields inherited from class de.unibi.techfak.jpredictor.clustering.VectorRelationMeasure |
|---|
vectorList |
| Fields inherited from class de.unibi.techfak.jpredictor.clustering.RelationMeasure |
|---|
computationResult |
| Fields inherited from interface de.unibi.techfak.jpredictor.clustering.Computable |
|---|
COMPUTATION_FAILED, COMPUTATION_PENDING, COMPUTATION_SUCCESS, COMPUTATION_WAITING |
| Constructor Summary | |
|---|---|
MinkowskiDistance(double p)
Inits the Minkowski distance measure. |
|
| Method Summary | |
|---|---|
double |
atomicCombine(double rel0,
double rel1)
Two relations measures are combined to one result, which is not stored but returned. |
double |
atomicNormalize(double rel,
double norm)
A relations measures is normalized by a certain amount. |
static double |
calculate(double[] x,
double[] y,
double p)
Calculates the Minkowski distance between two given arrays. |
int |
compute()
Uses all internal informations available and starts and controlls the computational process. |
double |
getP()
Returns the exponents value of the Minkowski Distance. |
RelationMeasure |
newInstance()
Creates a copy of this relation measure as if it was newly instantiated through a call to the constructor. |
int |
optimum(double rel0,
double rel1)
Compares two relation measure results. |
(package private) void |
setP(double p)
Sets the new exponent for the Minkowski Distance. |
java.lang.String |
toString()
Creates a short string of this relation measure and maybe some results if available. |
| Methods inherited from class de.unibi.techfak.jpredictor.clustering.VectorRelationMeasure |
|---|
add, add, add, clear, length |
| Methods inherited from class de.unibi.techfak.jpredictor.clustering.RelationMeasure |
|---|
atomicCombine, compareTo, optimum, result |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
double p
| Constructor Detail |
|---|
public MinkowskiDistance(double p)
throws java.lang.IllegalArgumentException
p - The exponent of the Minkowski distance measure.
java.lang.IllegalArgumentException - If p is zero or less than zero.| Method Detail |
|---|
public double getP()
void setP(double p)
throws java.lang.IllegalArgumentException
p - The new exponent.
java.lang.IllegalArgumentException - If p is zero or less than zero.public int compute()
Computable
COMPUTATION_SUCCESS.Computable.COMPUTATION_SUCCESS,
Computable.COMPUTATION_FAILED
public int optimum(double rel0,
double rel1)
RelationMeasure
Compares two relation measure results. Returns -1, zero or 1, if the
first (rel0) measure is worse, equal, or better than the
second one (rel1). The terms worse and better depend on
the implementation of the RelationMeasure inheriting
this method. Usually, when dealing with distances, the lower the better.
On the other side, when dealing with likelihoods the higher the better.
Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.
optimum in class RelationMeasurerel0 - The first relation measure to be compared to the second.rel1 - The second relation measure to be compared to the first.
public static double calculate(double[] x,
double[] y,
double p)
Double.NaN in case of any error, e.g. x or
y are null or of inequal length, or
p is less or equal zero.
x - The first array.y - The second arrayp - The exponent of calculation.
public double atomicCombine(double rel0,
double rel1)
RelationMeasureTwo relations measures are combined to one result, which is not stored but returned. This method provides a way to calculate the combined result, when the way how to do this is not known. For instance, distance relation measures normally sum up over single results while likelihood/probabilities are multiplied.
Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.
atomicCombine in class RelationMeasurerel0 - The first relation measure to be compared to the second.rel1 - The second relation measure to be compared to the first.
public double atomicNormalize(double rel,
double norm)
RelationMeasureA relations measures is normalized by a certain amount. This method provides a way to normalize a relation measure after numbers of them were combined. For instance, distance relation measures normally are normalized by dividing through the count, while likelihoods are rooted.
Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.
atomicNormalize in class RelationMeasurerel - The relation measure to be normalized.norm - The normalization value.
Double.NaN in case of error.public RelationMeasure newInstance()
RelationMeasure
newInstance in class RelationMeasurepublic java.lang.String toString()
RelationMeasure
toString in class RelationMeasure
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||