HTBasic Help
×
Menu
Index
Power_spectrum
Calculate power spectral density.
 
Loading        LOADSUB ALL FROM "FFT.HTS"
or LOADSUB Power_spectrum FROM "MATHLIB.HTS"
or LOADSUB FROM "MATHLIB.HTS"
 
Usage                INTEGER Logn
REAL A(*),B(*)
CALL Power_spectrum(Logn,A(*),B(*))
 
Description                
Power_spectrum calculates the power spectral density of the data in the array A and returns the information in the array B. Logn is the base-2 logarithm of the number of points in the sequence to be correlated. The array A must have at least 2Logn elements; if it has more than this number of elements, the extra elements are ignored. The array B must have at least 2Logn+1 elements; if it has more than this number of elements, the extra elements are unmodified. The number of elements in A denoted by each permitted value of Logn is shown in the table below:
 
Logn                No. Elements (2Logn)
2                4
3                8
4                16
5                32
6                64
7                128
8                256
9                512
10                1024
11                2048
12                4096
13                8192
14                16384
 
 
If N = 2Logn, after Power_spectrum has run, the first N/2 elements in the array B contain the power spectral density of A. The second N/2 elements in B contain zeros.
 
If the values in A are taken to be values of a continuous complex signal, a(t), sampled at constant intervals of T (time, distance, or whatever units apply), and if the signal sampled contained no terms at or above the frequency 1/2T, then the first N/2 elements in the array B are proportional to the power at the frequencies k/2NT, where k is the position in B, beginning with k = 0.
 
The power spectral density of a set of data is the Fourier transform of the autocorrelation of that set of data.
 
Errors                
Power_spectrum causes an HTBasic error if its arguments are not of the types shown in the USAGE section, above, if Logn is not between 2 and 15, inclusive, or if the size of A or B is smaller than the values described above.
 
See Also
Autocorrelate, Power_spectrum