set.seed(1234567)
gam<-4
gamest<-gam
g <- function(x) 3*sin(x*(gam*pi))+5*cos(x*(gam*pi))+6*x
sigma<-3
xx<-seq(0,1,length=100)
yy<-g(xx)+rnorm(100,sd=sigma)
zz<-xx
h1<-dpilc(xx,yy)
local_fit<-t(lprOperator(h=h1,xx=xx,zz=zz,p=2))%*%yy
y_sharp<-data_sharpening(xx=xx,yy=yy,zz=zz,p=2,gammaest=gamest,penalty="Periodicity")
sharp_fit<-t(lprOperator(h=h1,xx=xx,zz=zz,p=2))%*%y_sharp
plot(c(min(xx),max(xx)),c(min(yy)-0.5,max(yy)+0.5),type="n",,xlab="x",ylab="y")
legend("bottomright",legend=c("curve_local","curve_sharpen"), col=c(1,3),bty="n",pch=c("-","-"))
lines(xx,local_fit)
lines(xx,sharp_fit,col=3, lwd=2)
points(xx,yy,col= rgb(0.8,0.2,0.2,0.2))
Run the code above in your browser using DataLab