Description Usage Arguments Details Value Spectrum sidedness and the src argument Author(s) See Also Examples
Normalize power spectral densities from various estimators into single-sided spectra.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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? |
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.
An object with its spectral values normalized accordingly.
src
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:
stats::spectrum
RSEIS::mtapspec
"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
A.J. Barbour
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## Not run: #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']])
## End(Not run)#REX
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.