Negative powers in Lomb-Scargle periodogram
See original GitHub issueI’ve been using Astropy’s Lomb-Scargle periodogram for some time but just run into an unexpected scenario. I’ve attached a simple series of 19440 points of Gaussian noise (WN_1000_timeseries.txt), generated using 1000*numpy.random.randn(19440)
. When I compute the Lomb-Scargle periodogram, however, the second-last element has negative power. I was under the impression that this wasn’t possible but I appreciate that I may well be wrong, in which case this issue can be resolved by me understanding the LS periodogram better!
The timeseries is attached and this snippet of code produces the negative value for me.
import numpy as np
from astropy.stats import LombScargle
y = np.loadtxt('WN_1000_timeseries.txt')
f, p = LombScargle(np.arange(len(y), dtype=float), y, center_data=False).autopower(normalization='psd', samples_per_peak=1, nyquist_factor=1)
print(p[-2]) # -2493.908823582499
I’m running Python 3.7.2 on Fedora 29, with NumPy 1.16.0 and Astropy 3.1.2.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Understanding the Lomb–Scargle Periodogram - IOPscience
The Lomb–Scargle periodogram is a method that allows efficient computation of a Fourier-like power spectrum estimator from such unevenly sampled data, ...
Read more >Lomb-Scargle Periodograms
The Lomb-Scargle periodogram fits a sinusoidal model to the data at each frequency, with a larger power reflecting a better fit. With this...
Read more >Introduction To The Lomb-Scargle Periodogram (Lecture III)
LSSTC DSFP Session 13 Introduction to the Lomb-Scargle Periodogram. ... The Periodogram for Power Spectrum Estimation. Barry Van Veen.
Read more >Application of the Lomb-Scargle Periodogram to ... - NCBI
This paper examines the effect of common preprocessing methods on the Lomb–Scargle power spectral density estimate using both real and synthetic ...
Read more >Significance of periodogram peaks and a pulsation mode ...
Equivalently, a power value PX(ω) > z0 has probability 1 −p0 of being due to pure noise alone. This test is primitive and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The default computational approach is an approximation that speeds the algorithm from
O[N^2]
toO[N log N]
, at the expense of not producing exact results. For values close to zero, this approximation can lead to negative powers.If exact results are important to you, you can specify the
method
argument of theautopower
function to something other than"fast"
.For what it’s worth, I don’t think 1% inaccuracies at high frequencies are worth worrying about. In practice, the signal at such frequencies is so dominated by aliasing effects that a 1% inaccuracy is not going to make any substantive difference in the interpretation of periodograms.