oceSpectrum: Wrapper to give normalized spectrum

Description Usage Arguments Value Author(s) See Also Examples

View source: R/misc.R

Description

This is a wrapper around the R spectrum() function, which returns spectral values that are adjusted so that the integral of those values equals the variance of the input x.

Usage

1

Arguments

x

a univariate or multivariate time series, as for spectrum().

...

extra arguments passed on to spectrum().

Value

A spectrum that has values that integrate to the variance.

Author(s)

Dan Kelley

See Also

spectrum().

Examples

1
2
3
4
5
6
  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")

Example output

Loading required package: testthat
Loading required package: gsw
variance of x= 1.017324 
integral of     spectrum= 0.5082312 
integral of oce.spectrum= 1.017324 

oce documentation built on March 28, 2021, 9:09 a.m.