R/FourierRand.R

Defines functions FourierRand

Documented in FourierRand

FourierRand <-
function(x){
  n <- length(x)
  z <- fft(x)

  if(n%%2 == 0){
    ph <- 2*pi*runif(n/2-1)
    ph <- c(0, ph, 0, -rev(ph))}

  if(n%%2 != 0){
    ph <- 2*pi*runif((n-1)/2)
    ph <- c(0, ph, -rev(ph))}

  ph <- complex(imaginary = ph)
  z <- z * exp(ph)
  x.sur <- Re(fft(z, inverse = TRUE)/n)
  
  return(invisible(x.sur))
}

## Code: Tian, H. and Cazelles, B., \code{WaveletCo}

Try the WaveletComp package in your browser

Any scripts or data that you put into this service are public.

WaveletComp documentation built on May 2, 2019, 6:33 a.m.