Learn R Programming

psd (version 2.1.2)

psd-normalization: Normalization of power spectral density estimates.

Description

Normalize power spectral densities from various estimators into single-sided spectra.

Usage

normalize(Spec, ...)

# S3 method for list normalize(Spec, ...)

# S3 method for spec normalize( Spec, Fsamp = 1, src = c("spectrum", "double.sided", "psd", "single.sided"), verbose = TRUE, ... )

# S3 method for amt normalize(Spec, ...)

Value

An object with its spectral values normalized accordingly.

Arguments

Spec

spectrum to normalize

...

(unused) additional parameters

Fsamp

sampling frequency

src

character string; the source of the spectrum estimator

verbose

logical; should messages be given?

Spectrum sidedness and the <code>src</code> argument

"double.sided" or "spectrum"

These spectra assume frequency range of \([-F_S/2,F_S/2]\), and so are normalized by scaling by a factor of two upwards. Some estimators producing double-sided spectra:

"single.sided" or "psd"

As mentioned before, these spectra assume frequency range of \([0,F_S/2]\) and are scaled only by the inverse of the sampling rate. Some estimators producing single-sided spectra:

  • psdcore

Author

A.J. Barbour

Details

Normalizations commonly encountered for power spectra depend on it's assumed sidedness: whether the spectrum is either single- or double-sided. The normalizations performed here enforce single-sidedness, and correct as necessary.

Frequencies are assumed to be based on the Nyquist frequency (half the sampling rate). For example: If a series \(X\) has sampling frequency \(F_S\), then the PSD frequencies will span \([0,F_S/2]\).

For amplitudes, improper normalization can can introduce errant factors of either 1/2 or \(F_S\) into the estimates, depending on the assumed sidedness. These factors can be accounted for with the src argument, which defaults to normalizing a double-sided spectrum.

See Also

psdcore, spectral_properties

Examples

Run this code
if (FALSE) #REX
library(psd)

##
## Normalization
##

# timeseries with sampling frequency **not** equal to 1:
set.seed(1234)
X <- ts(rnorm(1e3), frequency=20)

# spec.pgram: double sided
pgram <- spectrum(X)

# psdcore: single sided
PSD <- psdcore(X)

# note the normalization differences:
plot(pgram, log="dB", ylim=c(-40,10))
plot(PSD, add=TRUE, col="red", log="dB")

# A crude representation of integrated spectrum: 
#   should equal variance of white noise series (~= 1)
mean(pgram[['spec']]) * max(pgram[['freq']])
mean(PSD[['spec']]) * max(PSD[['freq']])

# normalize 
pgram <- normalize(pgram, src="spectrum")
PSD <- normalize(pgram, src="psd")
# replot them
plot(pgram, log="dB", ylim=c(-40,10))
plot(PSD, add=TRUE, col="red", log="dB")

# Again, integrated spectrum should be ~= 1:
mean(pgram[['spec']]) * max(pgram[['freq']])
mean(PSD[['spec']]) * max(PSD[['freq']])


#REX

Run the code above in your browser using DataLab