DTWDT Functions
These are fundamental functions to calculate DTW distance distance array and DTW error between two time series.
DTWDT.DTWDTfunctions.computeErrorFunction — Function.USAGE: err = computeErrorFunction( u1, u0, nSample, lag )
INPUT:
u1 = trace that we want to warp; size = (nsamp,1)
u0 = reference trace to compare with: size = (nsamp,1)
nSample = numer of points to compare in the traces
lag = maximum lag in sample number to search
norm = 'L2' or 'L1' (default is 'L2')
OUTPUT:
err = the 2D error function; size = (nsamp,2*lag+1)The error function is equation 1 in Hale, 2013.
You could umcomment the L1 norm and comment the L2 norm if you want on Line 29
Original by Di Yang Last modified by Dylan Mikesell (25 Feb. 2015)
DTWDT.DTWDTfunctions.accumulateErrorFunction — Function.USAGE: d = accumulationdiwmod( dir, err, nSample, lag, b )
INPUT:
dir = accumulation direction ( dir > 0 = forward in time, dir <= 0 = backward in time)
err = the 2D error function; size = (nsamp,2*lag+1)
nSample = numer of points to compare in the traces
lag = maximum lag in sample number to search
b = strain limit (integer value >= 1)
OUTPUT:
d = the 2D distance function; size = (nsamp,2*lag+1)The function is equation 6 in Hale, 2013.
Original by Di Yang Last modified by Dylan Mikesell (25 Feb. 2015)
DTWDT.DTWDTfunctions.backtrackDistanceFunction — Function.USAGE: stbar = backtrackDistanceFunction( dir, d, err, lmin, b )
INPUT:
dir = side to start minimization ( dir > 0 = front, dir <= 0 = back)
d = the 2D distance function; size = (nsamp,2*lag+1)
err = the 2D error function; size = (nsamp,2*lag+1)
lmin = minimum lag to search over
b = strain limit (integer value >= 1)
OUTPUT:
stbar = vector of integer shifts subject to |u(i)-u(i-1)| <= 1/b
The function is equation 2 in Hale, 2013.
Original by Di Yang Last modified by Dylan Mikesell (19 Dec. 2014)
DTWDT.DTWDTfunctions.computeDTWerror — Function.Compute the accumulated error along the warping path for Dynamic Time Warping.
USAGE: function error = computeDTWerror( Aerr, u, lag0 )
INPUT:
Aerr = error MATRIX (equation 13 in Hale, 2013)
u = warping function (samples) VECTOR
lag0 = value of maximum lag (samples) SCALAR
Written by Dylan Mikesell Last modified: 25 February 2015