Package ai.libs.jaicore.basic.metric
Class DerivateDistance
- java.lang.Object
-
- ai.libs.jaicore.basic.metric.AWeightedTrigometricDistance
-
- ai.libs.jaicore.basic.metric.DerivateDistance
-
- All Implemented Interfaces:
org.api4.java.common.math.IMetric<double[]>
,IDistanceMetric
public class DerivateDistance extends AWeightedTrigometricDistance
Implementation of the Derivate Distance (DD) measure as published in "Using derivatives in time series classification" by Tomasz Gorecki and Maciej Luczak (2013). The authors wanted to create a distance measure which considers both, the function values of times series (point to point comparison) and the values of their derivates (general shape comparison). Given a distance measured
, the Derivate Distance for the two time seriesA
andB
is:a * d(A, B) + b * d(A', B')
, whereA'
andB'
are the derivates (@see jaicore.ml.tsc.filter.derivate) ofA
andB
respec. and0 <= a <= 1, 0 <= b <= 1>
are parameters of the measure. The parametersa
andb
are set via analpha
value, that isa=cos(alpha)
andb=sin(alpha)
. The Derivate Distance that uses Dynamic Time Warping as underlying distance measure is commonly denoted as DD_DTW. The Derivate Distance that uses the Euclidean distance as underlying distance measure is commonly denoted as DD_ED.It is also possible to use a distinct distance measure to calculate the distance between the time series and its derivates.
-
-
Constructor Summary
Constructors Constructor Description DerivateDistance(double alpha, ADerivateFilter derivate, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and derivate values.DerivateDistance(double alpha, ADerivateFilter derivate, IDistanceMetric timeSeriesDistance, IDistanceMetric derivateDistance)
Constructor with individual distance measures for the function and derivate values.DerivateDistance(double alpha, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and derivate values that uses theBackwardDifferenceDerivate
as derivation.DerivateDistance(double alpha, IDistanceMetric timeSeriesDistance, IDistanceMetric derivateDistance)
Constructor with individual distance measures for the function and derivate values that uses theBackwardDifferenceDerivate
as derivation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(double[] a, double[] b)
Calculates the distance between two time series.-
Methods inherited from class ai.libs.jaicore.basic.metric.AWeightedTrigometricDistance
getA, getAlpha, getB, setAlpha
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.api4.java.common.metric.IDistanceMetric
getDistance
-
-
-
-
Constructor Detail
-
DerivateDistance
public DerivateDistance(double alpha, ADerivateFilter derivate, IDistanceMetric timeSeriesDistance, IDistanceMetric derivateDistance)
Constructor with individual distance measures for the function and derivate values.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.derivate
- The derivate calculation to use.timeSeriesDistance
- The distance measure to use to calculate the distance of the derivate values.derivateDistance
- The distance measure to use to calculate the distance of the derivate values.
-
DerivateDistance
public DerivateDistance(double alpha, IDistanceMetric timeSeriesDistance, IDistanceMetric derivateDistance)
Constructor with individual distance measures for the function and derivate values that uses theBackwardDifferenceDerivate
as derivation.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.timeSeriesDistance
- The distance measure to use to calculate the distance of the derivate values.derivateDistance
- The distance measure to use to calculate the distance of the derivate values.
-
DerivateDistance
public DerivateDistance(double alpha, ADerivateFilter derivate, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and derivate values.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.derivate
- The derivate calculation to use.distance
- The distance measure to use to calculate the distance of the function and derivate values.
-
DerivateDistance
public DerivateDistance(double alpha, IDistanceMetric distance)
Constructor that uses the same distance measures for the function and derivate values that uses theBackwardDifferenceDerivate
as derivation.- Parameters:
alpha
- The distance measure to use to calculate the distance of the function values.0 <= alpha <= pi/2
.distance
- The distance measure to use to calculate the distance of the function and derivate values.
-
-
Method Detail
-
distance
public double distance(double[] a, double[] b)
Description copied from interface:IDistanceMetric
Calculates the distance between two time series.- Parameters:
a
- The influence of distance of the function values to the overall distance measureb
- The influence of distance of the derivates values to the overall distance measure.- Returns:
- Distance between the first and second time series.
-
-