New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scipy.signal.spectral.lombscargle is unclear about normalisation of Periodogram (Trac #1637) #2162
Comments
trac user pschella wrote on 2012-04-01 Although I like the idea of normalizing in principle, I do think we should give the user the option of turning it off for increased speed. |
@rgommers wrote on 2012-04-01 For fft a choice (fft nisn't normalized, ifft is normalized by 1/N) is made and that choice is documented. No choice is given to the user, because multiplying the output by a constant factor is just as easy as specifying normalization with a keyword. The normalization here seems to be more than multiplying by a constant though, so it may be good to implement. For backwards compatibility the default should be normalize=False I think. |
Just ran in to this problem, 2 years later. A simple 1 sentence addition to the docstring would have saved me a couple hours of frustration. It could be as simple as:
|
Sorry, this dropped of my radar completely.
But I will have to look into it in a bit more detail next week before I send a pull request upstream. Thanks! Regards, Pim Schellart
|
@pschella if you're going to look at this, @jakevdp just happened to write a blog post about this exact same topic (and a few more): https://jakevdp.github.io/blog/2015/06/13/lomb-scargle-in-python/. |
Thanks for the info! It is definitely an interesting post. I think it would
|
Quirk 1, mean has to be zero: if the results are simply incorrect if this is not the case, then this can be fixed without adding a keyword right? Return values may change then, but only for cases where the current return value isn't right anyway. Quirk 2, non-normilized output: this is more a convention than the current return values being incorrect, so here I'd say add a Quirk 3, angular frequencies: this is correctly documented and not a big deal, so leave as is? |
Adding a |
Adding an O(N logN) method sounds attractive, would be a nice enhancement. Do note though that that's not the only thing that Gatspy has over the Scipy implementation - see for example the period grid selection. So linking to Gatspy in the docs remains a good idea. |
One place where automatically pre-centering the data would break current code: if you are passing-in an array of 1s to find the power associated with your observing window, centering the data leads to garbage. |
Automatically subtracting the mean first will give a computational overhead On Sun, Jun 14, 2015 at 6:36 PM, Jake Vanderplas notifications@github.com
|
Attachments don't come through on Github. Can you open a pull request labeled Work In Progress to show us your changes? |
Done. On Fri, Jun 19, 2015 at 3:37 PM, Jake Vanderplas notifications@github.com
|
Thanks! Moving discussion there. |
I ran into the same normalization problem earlier this week and was later pointed to this thread by my instructor. |
Original ticket http://projects.scipy.org/scipy/ticket/1637 on 2012-03-30 by trac user hamogu, assigned to @cournape.
While this routine calculates the Lomb-Scargle periodogram beautifully, it does not address the normalization. This is mentioned in passing in the 'Examples' section of the documentation, but I suggest to either
or
extent the documentation string in the following way:
Parameters
x : array_like
Sample times.
y : array_like
Measurement values. If y obeys
y.mean()=0
andy.var()=1
then the periodogram returned by this function will follow the normalization of [2] and thus allows to calculate the false alarm probability (FAP).freqs : array_like
Angular frequencies for output periodogram.
Additionally, it might be useful to provide a function in signal.spectral to calculate the value of the periodogram for a given FAP.
The text was updated successfully, but these errors were encountered: