| LPDistance | R Documentation |
Computes the distance based on the chosen Lp norm between a pair of numeric vectors.
LPDistance(x, y, method="euclidean", ...)
x |
Numeric vector containing the first time series. |
y |
Numeric vector containing the second time series. |
method |
A value in "euclidean", "manhattan", "infnorm", "minkowski". |
... |
If method="minkowski" a positive integer value must be specified for |
The distances based on Lp norms are computed between two numeric vectors using the following formulas:
Euclidean distance: √{(x_i-y_i)^2)}
Manhattan distance: ∑{|x_i-y_i|}
Infinite norm distance: \max{|x_i-y_i|}
Minkowski distance: √[p]{(x_i-y_i)^p)}
The two series must have the same length. Furthermore, in the case of the Minkowski distance, p must be specified as a positive integer value.
d |
The computed distance between the pair of series. |
Usue Mori, Alexander Mendiburu, Jose A. Lozano.
These distances are also implemeted in separate functions. For more information see EuclideanDistance, ManhattanDistance, MinkowskiDistance
and InfNormDistance
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.
# 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 different Lp distances # Euclidean distance LPDistance(example.series1, example.series2, method="euclidean") # Manhattan distance LPDistance(example.series1, example.series2, method="manhattan") # Infinite norm distance LPDistance(example.series1, example.series2, method="infnorm") # Minkowski distance with p=3. LPDistance(example.series1, example.series2, method="minkowski", p=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.