metric.lp | R Documentation |
Measures the proximity between the functional data and curves approximating
Lp-metric. If w = 1
approximates the Lp-metric by Simpson's rule. By
default it uses lp = 2
and weights w = 1
.
metric.lp(fdata1, fdata2 = NULL, lp = 2, w = 1, dscale = 1, ...)
fdata1 |
Functional data 1 or curve 1. If |
fdata2 |
Functional data 2 or curve 2. If |
lp |
Lp norm, by default it uses |
w |
Vector of weights with length |
dscale |
If scale is a numeric, the distance matrix is divided by the scale value. If scale is a function (as the mean for example) the distance matrix is divided by the corresponding value from the output of the function. |
... |
Further arguments passed to or from other methods. |
By default it uses the L2-norm with lp = 2
.
f(x)= fdata1(x)-fdata2(x)
The observed points on each curve are equally spaced (by default) or not.
The L∞-norm is computed with lp = 0
.
d(fdata1(x),fdata2(x))_{∞}=sup ≤ft|fdata1(x)-fdata2(x)\right|
Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@udc.es
Febrero-Bande, M., Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. Journal of Statistical Software, 51(4), 1-28. https://www.jstatsoft.org/v51/i04/
See also semimetric.basis
and
semimetric.NPFDA
## Not run: # INFERENCE PHONDAT data(phoneme) mlearn<-phoneme$learn[1:100] mtest<-phoneme$test[1:100] glearn<-phoneme$classlearn[1:100] gtest<-phoneme$classtest[1:100] # Matrix of distances of curves of DATA1 mdist1<-metric.lp(mlearn) # Matrix of distances between curves of DATA1 and curves of DATA2 mdist2<-metric.lp(mlearn,mtest,lp=2) # mdist with L1 norm and weigth=v v=dnorm(seq(-3,3,len=dim(mlearn)[2])) mdist3<-metric.lp(mlearn,mtest,lp=1,w=v) plot(1:100,mdist2[1,],type="l",ylim=c(1,max(mdist3[1,]))) lines(mdist3[1,],type="l",col="2") # mdist with mlearn with different discretization points. # mlearn2=mlearn # mlearn2[["argvals"]]=seq(0,1,len=150) # mdist5<-metric.lp(mlearn,mlearn2) # mdist6<-metric.lp(mlearn2,mlearn) # sum(mdist5-mdist6) # sum(mdist1-mdist6) x<-seq(0,2*pi,length=1001) fx<-fdata(sin(x)/sqrt(pi),x) fx0<-fdata(rep(0,length(x)),x) metric.lp(fx,fx0) # The same integrate(function(x){(abs(sin(x)/sqrt(pi))^2)},0,2*pi) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.