#### example : composite of two components having different frequencies
## define vertex coordinate
x <- y <- seq(0, 1, length=30)
xy <- expand.grid(x=x, y=y)
## weighted adjacency matrix by Gaussian kernel
## for connecting vertices within distance 0.04
A <- adjmatrix(xy, method = "dist", 0.04)
## signal
# high-frequency component
signal1 <- rep(sin(12.5*pi*x - 1.25*pi), 30)
# low-frequency component
signal2 <- rep(sin(5*pi*x - 0.5*pi), 30)
# composite signal
signal0 <- signal1 + signal2
# noisy signal with SNR(signal-to-noise ratio)=5
signal <- signal0 + rnorm(900, 0, sqrt(var(signal0) / 5))
# graph with signal
gsig <- gsignal(vertex = cbind(xy, signal), edge = A, edgetype = "matrix")
# graph empirical mode decomposition (GEMD) without boundary treatment
out1 <- sgemd(gsig, nimf=3, smoothing=FALSE, boundary=FALSE)
# denoised signal by GEMD
dsignal1 <- out1$imf[[2]] + out1$imf[[3]] + out1$residue
# \donttest{
# statistical graph empirical mode decomposition (SGEMD) with boundary treatment
out2 <- sgemd(gsig, nimf=3, smoothing=TRUE, boundary=TRUE)
names(out2)
# denoised signal by SGEMD
dsignal2 <- out2$imf[[2]] + out2$imf[[3]] + out2$residue
# display of a signal, denoised signal, imf2, imf3 and residue by SGEMD
gplot(gsig, size=3)
gplot(gsig, dsignal2, size=3)
gplot(gsig, out2$imf[[2]], size=3)
gplot(gsig, out2$imf[[3]], size=3)
gplot(gsig, out2$residue, size=3)
# }
Run the code above in your browser using DataLab