Learn R Programming

longitudinalData (version 0.6.4)

pathFrechet: ~ Function: Frechet distance ~

Description

Compute Frechet distance and Frechet path between two trajectories.

Usage

pathFrechet(P, Q, method = "max", Fdist = dist)
pathFrechetR(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 and the Frechet path.

Details

Given two curve P and Q, given 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 Frechet path [...] The function pathFrechetR is code in R. The function pathFrechet is coded in C (and is thus much faster than the two other). Note that pathFrechet (the fastest) can only use the "2D" and "1D" distance.

References

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

See Also

distFrechet

Examples

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

   ### Optimized function
   pathFrechetR(P,Q)

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

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

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

Run the code above in your browser using DataLab