Learn R Programming

longitudinalData (version 0.6.4)

distFrechet: ~ Function: Frechet distance ~

Description

Compute Frechet distance between two trajectories.

Usage

distFrechet(P, Q, method = "max", Fdist = dist)
distFrechetR(P, Q, method = "max", Fdist = dist)
distFrechetRec(P, Q, method = "max", Fdist = dist)

Arguments

P
[vector(numeric)] First trajectories.
Q
[vector(numeric)] First trajectories.
method
[character] Method used. Can be either 'max' or 'sum'
Fdist
[numeric <- function(numeric,numeric)] Frechet distance between two trajectories use a distance that is use the compute the distance between points of the trajectories. Fdist can be used to define a specific distance. The special value "2D" is us

Value

  • A numeric value.

Details

Given two curve P and Q and a distance d, Frechet distance between P and Q is define as inf_{a,b} max_{t} d(P(a(t)),Q(b(t))). It's computation is a NP-complex problem. When P and Q are trajectories (discrete curve), the problem is polynomial (and quite simple). The Frechet distance can also be define using a sum instead of a max: inf_{a,b} sum_{t} d(P(a(t)),Q(b(t))) The function distFrechetRec use the recursive algorithm define by Thomas Eiter and Heikki Mannila. The function distFrechetR use a more efficiant algorithm in R. The function distFrechet use the efficiant algorithm in C (and is thus much faster than the two other). Note that distFrechet (the fastest) can only use the "2D" and "1D".

References

Thomas Eiter & Heikki Mannila: "Computing Discrete Fr�echet Distance"

See Also

distTraj

Examples

Run this code
P <- rnorm(7)
   Q <- rnorm(6)

   ### Function from Eiter and Mannila
   distFrechetRec(P,Q)

   ### Optimized function
   distFrechetR(P,Q)

   ### Function compiled in C
   distFrechet(P,Q)

   ### Frechet using sum instead of max.
   distFrechet(P,Q,method="sum")

   ### Frechet using "manhattan" distance
   distFrechetR(P,Q,Fdist=function(x)dist(x,method="manhattan"))

Run the code above in your browser using DataLab