Calculates the power spectrum.
Any series or multi-column table.
Optional. An integer, the FFT length. Defaults
to the length of the input series. If
A series or table.
max(W2) occurs at 0.2 Hz. with amplitude (5^2)/2 = 12.5.
mean(W1*W1) == 12.5
sum(W2) == 12.5
max(W2) == 12.5
max(W3) == 5.0
The power spectrum is calculated by the FFT and has the following form:
powspec(s) = 2*mag(fft(s)/length(s))^2
with a total of int(len/2) + 1 frequency values from 0 to Fs/2 Hz, where Fs is the sampling rate of the data (i.e. rate(s)). The first value (DC component) and the last value (at Fs/2, the Nyquist frequency) are not scaled by 2 to preserve Parsevalís theorem.
For an N term power spectrum where N is the length of the input series, by Parsevalís theorem, the sum of the power spectrum terms equals the mean of the series squared, i.e.:
sum(powspec(s)) == mean(s*s)
A sinewave of amplitude A, frequency F, sample interval T (where T = 1/Fs), and length L, yields a power spectrum with an amplitude of A2/2 at frequency F. If the input series is in Volts, the resulting power spectrum has units of V 2.
If len is larger than the length of series, the series is zero padded to length len before calculating the power spectrum. If len is less than the series length, the series is truncated to length len. If not specified, len defaults to the length of series.
See SPECTRUM to compute a magnitude normalized FFT.
See PSD to compute the power spectral density.
See WINFUNC for a list of windowing functions and amplitude correction schemes.
See DADiSP/FFTXL to optimize the underlying FFT computation.