Learn R Programming

WQM (version 0.1.4)

fun_icwt: Inverse of continuous wavelet transform

Description

Inverse of continuous wavelet transform

Usage

fun_icwt(x.wave, dt, dj, flag.wav = "WaveletComp", scale = NULL)

Value

reconstructed time series

Arguments

x.wave

input complex matrix.

dt

sampling resolution in the time domain.

dj

sampling resolution in the frequency domain.

flag.wav

String for two different CWT packages.

scale

Wavelet scales.

References

fun_stoch_sim_wave in PRSim, Brunner and Furrer, 2020.

Examples

Run this code
set.seed(100)

dt<-1
dj<-1/8
flag.wav <- switch(2, "wmtsa", "WaveletComp")

n <- 100
x <- rnorm(n)
x.wave <- t(WaveletComp::WaveletTransform(x=x)$Wave)
rec <- fun_icwt(x.wave, dt, dj, flag.wav)

x.wt <- WaveletComp::analyze.wavelet(data.frame(x=x),"x",dt=dt,dj=dj)
rec_orig <- WaveletComp::reconstruct(x.wt,only.sig = FALSE, plot.rec = FALSE)$series$x.r

### compare to original series
op <- par(mfrow = c(1, 1), mar=c(3,3,1,1), mgp=c(1, 0.5, 0))
plot(1:n, x, type="l", lwd=5, xlab=NA, ylab=NA)
lines(1:n, rec, col="red",lwd=3)
lines(1:n, rec_orig, col="blue", lwd=1)
legend("topright",legend=c("Raw","Inverse","Inverse_orig"),
       lwd=c(5,3,1),bg="transparent",bty = "n",
       col=c("black","red","blue"),horiz=TRUE)
par(op)

Run the code above in your browser using DataLab