This positive distance is the mean squared differences between x and the y, divided by the square of the number of times the x oscillates around the y (see note below for illustration).

distanceOscillation(x, y)

Arguments

x, y

numeric vectors of the same length.

Note

To illustrate this distance, suppose we observed a time series y = c(1,3,5,7,5,3,1) and we have two simulated time series x1 = (3,5,7,9,7,5,3) and x2 = (3,5,3,5,7,5,3); x1 is consistently above y and x2 oscillates around y. While the squared differences are the same, we obtain \(d(y, x1) = 4\) and \(d(y, x2) = 1.3\).