# INFERENCE PHONDAT
data(phoneme)
mlearn<-phoneme$learn
mtest<-phoneme$test
glearn<-phoneme$classlearn
gtest<-phoneme$classtest
# Matrix of distances of curves of DATA1
mdist1<-metric.lp(mlearn)
# Matrix of distances beetween curves of DATA1 and curves of DATA2
mdist2<-metric.lp(mlearn,mtest,p=2)
# mdist with L1 norm and weigth=v
v=dnorm(seq(-3,3,length.out=dim(mlearn)[2]-1))
mdist3<-metric.lp(mlearn,mtest,p=1,w=v)
plot(1:250,mdist2[1,],type="l",ylim=c(1,max(mdist2[1,])+1))
lines(mdist3[1,],type="l",col="2")
# mdist with mlearn with diferents 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)
# more examples
x<-seq(0,2*pi,length=1001)
fx<-sin(x)/sqrt(pi)
metric.lp(fx,rep(0,length(fx)),w=2*pi)
# The same
integrate(function(x){(abs(sin(x)/sqrt(pi))^2)},0,2*pi)Run the code above in your browser using DataLab