org.simulator.math
Class N_Metric

java.lang.Object
  extended by org.simulator.math.QualityMeasure
      extended by org.simulator.math.N_Metric
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EuclideanDistance, ManhattanDistance, RelativeSquaredError

public class N_Metric
extends QualityMeasure

An implementation of an n-metric. An n-metric is basically the nth root of the sum of the distances of every single element in two vectors (arrays), where this distance will always be exponentiated by the value of n.

Since:
1.0
Version:
$Rev: 392 $
Author:
Andreas Dräger, Roland Keller
See Also:
Serialized Form

Field Summary
protected  double root
          The n of the metric.
 
Fields inherited from class org.simulator.math.QualityMeasure
defaultValue, meanFunction
 
Constructor Summary
N_Metric()
          Constructs a new NMetric with a default root of two.
N_Metric(double root)
          Constructs a new NMetric with a customized root.
 
Method Summary
 double distance(MultiTable.Block.Column x, MultiTable.Block.Column y, double defaultValue)
          Returns the distance of the two vectors x and y with the given root.
 double distanceToZero(MultiTable.Block.Column x, double defaultValue)
           
 double getRoot()
          Returns the n of the metric.
 void setRoot(double root)
          Sets the root.
 
Methods inherited from class org.simulator.math.QualityMeasure
distance, distance, distance, getColumnDistances, getDefaultValue, getMeanFunction, setDefaultValue, setMeanFunction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected double root
The n of the metric.

Constructor Detail

N_Metric

public N_Metric()
Constructs a new NMetric with a default root of two. This will result in the Euclidean distance. Other metrics can be used by either setting the root to another value or explicitly using the distance function where the root must be given as an argument.


N_Metric

public N_Metric(double root)
Constructs a new NMetric with a customized root. Depending on the values of root this results in different metrics. Some are especially important:

Parameters:
root -
Method Detail

distance

public double distance(MultiTable.Block.Column x,
                       MultiTable.Block.Column y,
                       double defaultValue)
Description copied from class: QualityMeasure
Returns the distance of the two vectors x and y with the given root. This may be the root in a formal way or a default value to be returned if the distance uses a non defined operation. If one array is longer than the other one additional values do not contribute to the distance. Double.NaN values are also ignored.

Specified by:
distance in class QualityMeasure
Parameters:
x - an array
y - another array
defaultValue - The value to be returned in cases in which no distance computation is possible.
Returns:
The distance between the two arrays x and y.

getRoot

public double getRoot()
Returns the n of the metric.

Returns:
n

setRoot

public void setRoot(double root)
Sets the root.

Parameters:
root -

distanceToZero

public double distanceToZero(MultiTable.Block.Column x,
                             double defaultValue)
Parameters:
x - expected
defaultValue -
Returns:
the distance of the column vector x to the point of origin.

Generated at April 19 2013
Version 1.3 Revision 424