empiricalSpectrum | R Documentation |
Computes the "empirical power" of a time series via a discrete Fourier transform.
empiricalSpectrum(x, two.sided=FALSE)
x |
a time series ( |
two.sided |
a |
Performs a Fourier transform, and then derives (based on the
additional information on sampling rate etc. provided via the time
series' attributes) the spectral power as a function of frequency.
The result is simpler (in a way) than the spectrum()
function's output, see also the example below. What is returned is the
real-valued frequency series
kappa[j] * (deltat/N) * abs(DFT(x)(f[j]))^2
where j=0,...,N/2+1,
and f[j]=j / (N*deltat) are the
Fourier frequencies. deltat is the time series'
sampling interval and N is its
length. kappa[j] is =1 for zero and Nyquist
frequencies, and =2 otherwise, and denotes the number of (by
definition) non-zero Fourier coefficients. In case
two.sided=TRUE
, the kappa[j] prefactor is
omitted.
For actual spectral estimation purposes, the use of a windowing
function (see e.g. the tukeywindow()
function) is highly
recommended.
A list containing the following elements:
frequency |
the Fourier frequencies. |
power |
the spectral power. |
kappa |
the number of (by definition) non-zero imaginary components of the Fourier series. |
two.sided |
a |
Christian Roever, christian.roever@med.uni-goettingen.de
Roever, C., Meyer, R., Christensen, N. Modelling coloured residual noise in gravitational-wave signal processing. Classical and Quantum Gravity, 28(1):015010, 2011. doi: 10.1088/0264-9381/28/1/015010. See also arXiv preprint 0804.3853.
fft
,
spectrum
,
tukeywindow
,
welchPSD
# load example data: data(lh) # compute spectrum: spec1 <- empiricalSpectrum(lh) plot(spec1$frequency, spec1$power, log="y", type="b") # plot "spectrum()" function's result in comparison: spec2 <- spectrum(lh, plot=FALSE) lines(spec2$freq, spec2$spec, col="red") # make both spectra match: spec3 <- empiricalSpectrum(lh, two.sided=TRUE) spec4 <- spectrum(lh, plot=FALSE, taper=0, fast=FALSE, detrend=FALSE) plot(spec3$frequency, spec3$power, log="y", type="b") lines(spec4$freq, spec4$spec, col="green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.