public class MinkowskiDistance extends FunctionMetric
Minkowski Distance
between two lists of objects. This is
added as part of the som package, copied from the related source code. The power value can
be set through the initialisation config parameters, using AiHeuristicConst
.MKP
as
the key. The metric measures the sum[(ds1 - ds2)^p]^(1/p)
.
The MetricDataset
needs to use an indexed list instead of an ordered one.double arrays
, then they can be processed as is, without using the metric objects.
The desired result is a larger distance, but you can use the isBetter()
method to determine
what value is better. Null can be returned for invalid data.config, mathCompare, valueType
Constructor and Description |
---|
MinkowskiDistance()
Create a new instance of MinkowskiDistance.
|
MinkowskiDistance(java.lang.String thisValueType,
java.util.HashMap<java.lang.String,?> thisConfig)
Create a new instance of MinkowskiDistance.
|
Modifier and Type | Method and Description |
---|---|
double |
evaluate(double[] ds1,
double[] ds2,
int pow)
Evaluate the comparison between the two data lists and return the result.
|
ReplySet |
evaluate(MetricDataset ds1,
MetricDataset ds2)
Evaluate the comparison between the two data lists and return the result.
|
protected void |
initialise()
Initialise the function values, setting the config parameters or other.
|
boolean |
isBetter(java.lang.String valueType,
java.lang.Object value1,
java.lang.Object value2)
Return true if value2 is better than value1, as determined by the measurements of
this evaluation function.
|
FunctionMetric |
newInstance()
Create and return a new instance of the function, initialised with this function's
value type
valueType and mathOperation evaluator mathCompare . |
boolean |
sib()
Return true if a smaller distance between the two vectors is better.
|
evaluateCompare, lib
checkValueType, createFunction, createFunction, createFunction, evaluate, getConfigParams, innerObject, isLegalNumber, setConfigParams, setEvaluator, setValueType
public MinkowskiDistance() throws java.lang.Exception
java.lang.Exception
- any error.public MinkowskiDistance(java.lang.String thisValueType, java.util.HashMap<java.lang.String,?> thisConfig) throws java.lang.Exception
thisValueType
- the type of object being evaluated.thisConfig
- list of initialisation function-specific parameters.java.lang.Exception
- any error.protected void initialise() throws java.lang.Exception
initialise
in class Function
java.lang.Exception
- any error.public ReplySet evaluate(MetricDataset ds1, MetricDataset ds2) throws java.lang.Exception
evaluate
in interface FunctionMetricDef
evaluate
in class FunctionMetric
ds1
- first value dataset.ds2
- second value dataset.java.lang.Exception
- any error.public double evaluate(double[] ds1, double[] ds2, int pow) throws java.lang.Exception
ds1
- first value dataset.ds2
- second value dataset.pow
- the power and fraction power value.java.lang.Exception
- any error.public boolean isBetter(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2) throws java.lang.Exception
isBetter
in class FunctionMetric
valueType
- the java type of the values to be evaluated.value1
- the first value type.value2
- the second value type.java.lang.Exception
- any error.public boolean sib()
sib
in class FunctionMetric
public FunctionMetric newInstance() throws java.lang.Exception
valueType
and mathOperation evaluator mathCompare
.newInstance
in class FunctionMetric
java.lang.Exception
- any error.