Learn R Programming

TSdist (version 3.1)

EDRDistance: Edit Distance for Real Sequences (EDR).

Description

Computes the Edit Distance for Real Sequences between a pair of numeric time series.

Usage

EDRDistance(x, y, epsilon, sigma)

Arguments

x
Numeric vector containing the first time series.
y
Numeric vector containing the second time series.
epsilon
A positive threshold value that defines the distance.
sigma
If desired, a Sakoe-Chiba windowing contraint can be added by specifying a positive integer representing the window size.

Value

  • dThe computed distance between the pair of series.

Details

The basic Edit Distance for Real Sequences between two numeric series is calculated. The idea is to count the number of edit operations (insert, delete, replace) that are necessary to transform one series into the other. For that, if the Euclidean distance between two points $x_i$ and $y_i$ is smaller that epsilon they will be considered equal ($d=0$) and if they are farther apart, they will be considered different ($d=1$). As a last detail, this distance permits gaps or sequences of points that are not matched with any other point. The length of series x and y may be different. Furthermore, if desired, a temporal constraint may be added to the EDR distance. In this package, only the most basic windowing function, introduced by H.Sakoe and S.Chiba (1978), is implemented. This function sets a band around the main diagonal of the distance matrix and avoids the matching of the points that are farther in time than a specified $\sigma$. The size of the window must be a positive integer value, not larger than the size of both of the series. Furthermore, the following condition must be fulfilled: $$|length(x)-length(y)| < sigma$$

References

Chen, L., Ozsu, M. T., & Oria, V. (2005). Robust and Fast Similarity Search for Moving Object Trajectories. In Proceedings of the 2005 ACM SIGMOD International Conference on Management of Data (pp. 491-502).

See Also

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.

Examples

Run this code
# The objects example.series3 and example.series4 are two 
# numeric series of length 100 and 120 contained in the TSdist
# package. 

data(example.series3)
data(example.series4)

# For information on their generation and shape see 
# help page of example.series.

help(example.series)

# Calculate the EDR distance for two series of different length
# with no windowing constraint:

EDRDistance(example.series3, example.series4, epsilon=0.1)

# Calculate the EDR distance for two series of different length
# with a window of size 30:

EDRDistance(example.series3, example.series4, epsilon=0.1, sigma=30)

Run the code above in your browser using DataLab