Functions to compare patterns with shifted features. These functions compare warped sample patterns to one or more reference patterns. RMS returns the usual root-mean-squared difference measure; WCC returns 1-wcc, where wcc indicates the weighted cross-correlation. Perfect alignment leads to a value of 0 for both criteria.
Internal function, not meant to be called directly by the user. In
particular, note that the identity warping may lead to slightly
different estimates than a direct comparison of the reference and
sample signals - a warping even slightly outside the original range of
1 : ncol(ref)
leads to NA values.
RMS(warp.coef, ref, samp, B, mode)
WCC(warp.coef, ref, samp, B, trwdth = 20, wghts, mode, ref.acors = NULL)
a vector of warping coefficients
reference signal; a matrix with one or more rows. If the
number of rows is greater than one, it should equal the number of
rows in samp
sample signal; a matrix with one or more rows
basis for warping function
either "forward" (new implementation, also used for warping peak lists) or "backward" (classical implementation).
triangle width for the WCC function, expressed in the number of data points
optional weights vector, will be calculated from triangle width if necessary. Sometimes it is more efficient to pre-calculate it and give it as an argument
autocorrelation of the reference. Since the reference is often unchanged over multiple evaluations (e.g., during an optimization), it is useful to pre-calculate this number
One number - either the WCC or RMS value
All patterns in samp
are warped using the same warping
function, and then compared to ref
, either pair-wise (when
ref
and samp
are of the same size), or with the one
pattern in ref
.
Eilers, P.H.C. (2004) "Parametric Time Warping", Analytical Chemistry, 76 (2), 404 -- 411.
de Gelder, R., Wehrens, R. and Hageman, J.A. (2001) "A generalized expression for the similarity of spectra: Application to powder diffraction pattern classification", Journal of Computational Chemistry, 22, 273 -- 289.