Kullback–Leibler distance
Measures the proximity between two groups of densities (of class
fdata
) by computing the Kullback–Leibler distance.
metric.kl(fdata1, fdata2 = NULL, symm = TRUE, base = exp(1), eps = 1e-10, ...)
fdata1 |
Functional data 1 ( |
fdata2 |
Functional data 2 ( |
symm |
If |
base |
The logarithm base used to compute the distance. |
eps |
Tolerance value. |
... |
Further arguments passed to or from other methods. |
Kullback–Leibler distance between f(t) and g(t) is
dist(f(t),g(t))= \int_{a}^{b} f(t)* log(f(t)/g(t)) dt
where t are the m
coordinates of the points
where the density is observed (the argvals
of the fdata
object).
The Kullback–Leibler distance is asymmetric,
dist(f(t),g(t))!=dist(g(t),f(t))
A symmetry version of K–L distance (by default) can be obtained by
0.5*(dist(f(t),g(t))+dist(g(t),f(t)))
If (f(t)=0 and g(t)=0), then metric.kl(f(t),g(t))=0.
If abs(f(t)-g(t))<ε, then f(t)=f(t)+ε,
where ε is the tolerance value (by default eps=1e-10
).
The coordinates of the points where the density is observed (discretization points t) can be equally spaced (by default) or not.
Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@usc.es
Kullback, S., Leibler, R.A. (1951). On information and sufficiency. Annals of Mathematical Statistics, 22: 79-86
## Not run: n<-201 tt01<-seq(0,1,len=n) rtt01<-c(0,1) x1<-dbeta(tt01,20,5) x2<-dbeta(tt01,21,5) y1<-dbeta(tt01,5,20) y2<-dbeta(tt01,5,21) xy<-fdata(rbind(x1,x2,y1,y2),tt01,rtt01) plot(xy) round(metric.kl(xy,xy,eps=1e-5),6) round(metric.kl(xy,eps=1e-5),6) round(metric.kl(xy,eps=1e-6),6) round(metric.kl(xy,xy,symm=FALSE,eps=1e-5),6) round(metric.kl(xy,symm=FALSE,eps=1e-5),6) plot(c(fdata(y1[1:101]),fdata(y2[1:101]))) metric.kl(fdata(x1)) metric.kl(fdata(x1),fdata(x2),eps=1e-5,symm=F) metric.kl(fdata(x1),fdata(x2),eps=1e-6,symm=F) metric.kl(fdata(y1[1:101]),fdata(y2[1:101]),eps=1e-13,symm=F) metric.kl(fdata(y1[1:101]),fdata(y2[1:101]),eps=1e-14,symm=F) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.