# pathFrechet: ~ Function: Frechet distance ~ In kmlShape: K-Means for Longitudinal Data using Shape-Respecting Distance

## Description

Compute Frechet distance and Frechet path between two trajectories.

## Usage

 `1` ```pathFrechet(Px,Py,Qx,Qy,timeScale=0.1,FrechetSumOrMax = "sum") ```

## Arguments

 `Px` [vector(numeric)] Times (abscisse) of the first trajectories. `Py` [vector(numeric)] Values of the first trajectories. `Qx` [vector(numeric)] Times of the second trajectories. `Qy` [vector(numeric)] Values of the second trajectories. `timeScale` [`numeric`]: allow to modify the time scale, increasing or decreasing the cost of the horizontal shift. If timeScale is very big, then the Frechet path is only a set of vertical segment. If timeScale is very small, then it is equal to the path find by Dynamic Time Warping. `FrechetSumOrMax` [`character`]: Like Frechet's distance, the Frechet's path can be define using the 'sum' function or the 'max' function. This option let the user to chose one or the other.

## Details

Given two curve P and Q, Frechet distance between P and Q is define as `distFrechet(P,Q)=inf_{a,b} max_{t} d(P(a(t)),Q(b(t)))`.

The Frechet path is the couple of function `(a(t),b(t))` that realize the previous equality : `distFrechet(P,Q)=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.

The Frechet path 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 `pathFrechet` is C compiled whereas the function `pathFrechetR` is in R.

## Value

A numeric value and the Frechet path in a matrix.

## Author

Christophe Genolini \& Elie Guichard
1. UMR U1027, INSERM, Universit<e9> Paul Sabatier / Toulouse III / France
2. CeRSME, EA 2931, UFR STAPS, Universit<e9> de Paris Ouest-Nanterre-La D<e9>fense / Nanterre / France

## References

Thomas Eiter & Heikki Mannila: "Computing Discrete Fr<b4>echet Distance"

[1] C. Genolini and B. Falissard
"KmL: k-means for longitudinal data"
Computational Statistics, vol 25(2), pp 317-328, 2010

[2] C. Genolini and B. Falissard
"KmL: A package to cluster longitudinal data"
Computer Methods and Programs in Biomedicine, 104, pp e112-121, 2011

distFrechet

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ``` Px <- 1:20 Py <- dnorm(1:20,12,2) Qx <- 1:20 Qy <- dnorm(1:20,8,2) ### Function from Eiter and Mannila compiled in C system.time(pathFrechet(Px,Py,Qx,Qy)) ### Same thing in R system.time(pathFrechet(Px,Py,Qx,Qy)) ### Frechet using sum instead of max. pathFrechet(Px,Py,Qx,Qy,FrechetSumOrMax="sum") ```

### Example output

```Loading required package: class

Attaching package: 'kmlShape'

The following object is masked from 'package:longitudinalData':

distFrechet

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
call: fun(...)
user  system elapsed
0.003   0.000   0.004
user  system elapsed
0.016   0.000   0.016
P  Q
1   1  1
2   2  2
3   3  3
4   4  4
5   5  5
6   6  6
7   7  7
8   8  8
9   9  9
10 10 10
11 11 11
12 12 12
13 13 13
14 14 14
15 15 15
16 16 16
17 17 17
18 18 18
19 19 19
20 20 20
```

kmlShape documentation built on May 29, 2017, 10:19 a.m.