LSSpectrum - Maple Help

SignalProcessing

 LSSpectrum
 compute the Lomb-Scargle power spectrum of irregularly spaced data

 Calling Sequence LSSpectrum(t, f, options)

Parameters

 t - rtable ; the time f - rtable ; the signal

Options

 • outputdata : posint : specify the number of the output data points
 • errors : rtable or realcons
 • precise : truefalse : indicates the methods to use
 • minimumfrequency : float : indicates minimum frequency
 • maximumfrequency : float : indicates maximum frequency
 • normalization : identical('standard', 'model', 'log', 'psd') ; indicates the type of normalization
 • oversamplingfactor : numeric : indicates the oversampling factor
 • nyquistfactor : numeric : indicates the multiple of the average Nyquist frequency
 • centerdata : truefalse : indicates whether the data needs to subtract the weighted mean
 • generalized : truefalse : indicates the methods to use for the Lomb Scargle Fast Approximation

Description

 • The LSSpectrum(t, f) command computes the frequencies and power spectrum based on provided time and signal using Lomb Scargle Periodogram Method, and returns the result in an Array of datatype float[8].
 • f and t can only be Vectors or one-dimensional Arrays.
 • There are two ways to compute the Lomb Scargle Periodogram: one can compute the exact values, or an approximation. Computing the approximation is generally much faster. If the precise option is set to true, then the actual formula is used for computation, otherwise the fast approximation is used. The default value is false.
 • The errors option specifies the expected magnitude of the errors, which is used to get the normalized weight for generalized Lomb Scargle periodogram. It can only be a real number or an one-dimensional array. The default value is NULL.
 • The outputdata option specifies the number of output data points. These output data points correspond to equally spaced frequencies.
 • The minimumfrequency option specifies the minimum frequency.
 • The maximumfrequency option specifies the maximum frequency.
 • If one of maximumfrequency, minimumfrequency and outputdata is specified, then all of them must be provided. If all of them are not provided, then the frequencies used run from $\frac{1}{T\mathrm{oversamplingfactor}}$ to $\mathrm{nyquistfactor}\mathrm{Nf}$, where $T=\mathrm{max}\left(t\right)-\mathrm{min}\left(t\right)$ and $\mathrm{Nf}=\frac{n}{2T}$ where $n$ is the number of elements in t. Output frequencies are equally spaced.
 • The nyquistfactor option has a default value 1.
 • The normalization option controls the normalization used on the power and can be one of standard, model, log or psd. The default value is standard. Standard Normalization : ${P}_{\mathrm{standard}}\left(f\right)=\frac{{\mathrm{\chi }}_{\mathrm{ref}}^{2}-{\mathrm{\chi }\left(f\right)}^{2}}{{\mathrm{\chi }}_{\mathrm{ref}}^{2}}$. Model Normalization : ${P}_{\mathrm{model}}\left(f\right)=\frac{{\mathrm{\chi }}_{\mathrm{ref}}^{2}-{\mathrm{\chi }\left(f\right)}^{2}}{{\mathrm{\chi }\left(f\right)}^{2}}$. Logarithmic Normalization:  ${P}_{\mathrm{log}}\left(f\right)=\mathrm{log}\left(\frac{{\mathrm{\chi }}_{\mathrm{ref}}^{2}}{{\mathrm{\chi }\left(f\right)}^{2}}\right)$. PSD Normalization : ${P}_{\mathrm{psd}}\left(f\right)=\frac{{\mathrm{\chi }}_{\mathrm{ref}}^{2}}{2}-\frac{{\mathrm{\chi }\left(f\right)}^{2}}{2}$. In all normalization methods, let ${f}_{i}$ be the measurement in time ${t}_{i}$ with errors ${\mathrm{\sigma }}_{i}$, then ${\mathrm{\chi }\left(f\right)}^{2}=\sum _{i=1}^{n}\frac{{f}_{i}-{f\left({t}_{i}\right)}^{2}}{{\mathrm{\sigma }}_{i}^{2}}$ where $n$ is the number of elements in f, and ${\mathrm{\chi }}_{\mathrm{ref}}^{2}$ is the non-varying reference model which is the ${\mathrm{\chi }\left(f\right)}^{2}$ for weighted mean.
 • The oversamplingfactor option specifies the oversampling factor. The default value is 5.
 • If the centerdata=false option is provided, then the weighted mean will not be subtracted from signal data. The default value is true.
 • If the generalized=false option is provided, then the generalized Lomb Scargle Periodogram will not be used. The default value is true.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$

Generate a time vector

 > $t≔\mathrm{sort}\left(\mathrm{LinearAlgebra}:-\mathrm{RandomVector}\left(200,\mathrm{generator}=0..12\mathrm{\pi },\mathrm{datatype}=\mathrm{float}\left[8\right]\right)\right)$
 ${{\mathrm{_rtable}}}_{{36893628672700452980}}$ (1)

Generate a signal using frequencies of 1 Hz and 2 Hz:

 > $\mathrm{f1}≔1.0:$
 > $\mathrm{f2}≔2.0:$
 > $s≔\mathrm{Vector}\left(200,i↦\mathrm{sin}\left(2\cdot \mathrm{f1}\cdot \mathrm{\pi }\cdot t\left[i\right]\right)+1.5\cdot \mathrm{sin}\left(2\cdot \mathrm{f2}\cdot \mathrm{\pi }\cdot t\left[i\right]\right),\mathrm{datatype}=\mathrm{float}\left[8\right]\right)$
 ${{\mathrm{_rtable}}}_{{36893628672572224084}}$ (2)
 > $\mathrm{frequency},\mathrm{power}≔\mathrm{LSSpectrum}\left(t,s\right)$
 ${\mathrm{frequency}}{,}{\mathrm{power}}{≔}\begin{array}{c}\left[\begin{array}{c}{0.00535064259664831}\\ {0.0107012851932966}\\ {0.0160519277899449}\\ {0.0214025703865932}\\ {0.0267532129832415}\\ {0.0321038555798898}\\ {0.0374544981765381}\\ {0.0428051407731864}\\ {0.0481557833698347}\\ {0.0535064259664830}\\ {⋮}\end{array}\right]\\ \hfill {\text{500 element Vector[column]}}\end{array}{,}\begin{array}{c}\left[\begin{array}{c}{0.0252943323722018}\\ {0.0424221928083066}\\ {0.0410349940822068}\\ {0.0367099094135614}\\ {0.0298409949960726}\\ {0.0201610955998152}\\ {0.00944568419860137}\\ {0.00130431560673459}\\ {0.00227218373253344}\\ {0.00868133821532043}\\ {⋮}\end{array}\right]\\ \hfill {\text{500 element Vector[column]}}\end{array}$ (3)
 > $\mathrm{plot}\left(\mathrm{frequency},\mathrm{power}\right)$
 > 

References

 Lomb, Nicholas R. "Least-Squares Frequency Analysis of Unequally Spaced Data." Astrophysics and Space Science. Vol. 39, 1976, pp. 447–462.
 Press, William H., and Rybicki, George B. "Fast Algorithm for Spectral Analysis of Unevenly Sampled Data." Astrophysical Journal. Vol. 338, 1989, pp. 277–280.
 Zechmeister, M., and Kürster, M. "The generalised Lomb-Scargle periodogram. A new formalism for the floating-mean and Keplerian periodograms." Astronomy & Astrophysics. Vol. 496, 2009, pp. 577-584

Compatibility

 • The SignalProcessing[LSSpectrum] command was introduced in Maple 2019.