
Computes the Manhattan distance between a pair of numeric vectors.
ManhattanDistance(x, y)
Numeric vector containing the first time series.
Numeric vector containing the second time series.
The computed distance between the pair of series.
The Manhattan distance is computed between the two numeric series using the following formula:
The two series must have the same length. This distance is calculated with the help of the dist
function of the proxy
package.
David Meyer and Christian Buchta (2015). proxy: Distance and Similarity Measures. R package version 0.4-14. http://CRAN.R-project.org/package=proxy
This function can also be invoked by the wrapper function LPDistance
.
Furthermore, to calculate this distance measure using ts
, zoo
or xts
objects see TSDistances
. To calculate distance matrices of time series databases using this measure see TSDatabaseDistances
.
# NOT RUN {
# The objects example.series1 and example.series2 are two
# numeric series of length 100 contained in the TSdist package.
data(example.series1)
data(example.series2)
# For information on their generation and shape see help
# page of example.series.
help(example.series)
# Compute the Manhattan distance between them:
ManhattanDistance(example.series1, example.series2)
# }
Run the code above in your browser using DataLab