oceSpectrum: Normalize a Spectrum

View source: R/oce.R

oceSpectrumR Documentation

Normalize a Spectrum

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

oceSpectrum(x, ...)

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

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")

oce documentation built on Sept. 11, 2024, 7:09 p.m.