x <- rnorm(1e3)
s <- spectrum(x, plot = FALSE)
ss <- oce.spectrum(x, plot = FALSE)
cat("variance of x=", var(x), "\n")
cat("integral of spectrum=", sum(s$spec) * diff(s$freq[1:2]), "\n")
cat("integral of oce.spectrum=", sum(ss$spec) * diff(ss$freq[1:2]), "\n")
Run the code above in your browser using DataLab