LombScargle.jl icon indicating copy to clipboard operation
LombScargle.jl copied to clipboard

Reuse Lombscargle.PeriodogramPlan for different signal but the same time vector

Open felixcremer opened this issue 4 years ago • 2 comments

I am currently implementing a time series surrogate algorithm based on the lombscargle periodogram https://github.com/JuliaDynamics/TimeseriesSurrogates.jl/pull/67. There I need to compute the lombscargle periodogram for shuffled versions of the same signal with the same times vector a few thousand times. I benchmarked my implementation and most of the time is spent in the computation of the lombscargle periodogram.

Is there a way to reuse the Lombscargle PeriodogramPlan for this so that I could update the signal of the PeriodogramPlan?

I have seen the bootstrap methods in this package, but I don't understand, why this shuffles the times vector, but from that I would assume, that something similar for the signal might be feasible.

felixcremer avatar Jun 02 '20 15:06 felixcremer

I have seen the bootstrap methods in this package, but I don't understand, why this shuffles the times vector, but from that I would assume, that something similar for the signal might be feasible.

Quoting from the documentation:

the LombScargle.PeriodogramPlan bears the time vector, but the quantities that are pre-computed in planning stage do not actually depend on it. This is particularly useful if you want to calculate the false-alarm probability via bootstrapping with LombScargle.bootstrap function: the vector time is randomly shuffled, but pre-computed quantities will remain the same, saving both time and memory in each iteration.

For bootstrap, shuffling the times or the signal is just the same. The quantities that are pre-computed depends on the signal, so it's just much more efficient to keep it fixed and shuffle the times.

I'm not sure there would be any advantage in a plan that has the same time vector but different signals, you can't cache almost anything

giordano avatar Jun 02 '20 16:06 giordano

I'm not sure there would be any advantage in a plan that has the same time vector but different signals, you can't cache almost anything

Looking at src/planning.jl, maybe the FFTW plan could be reused in the case of the FastGLSPlan* plans, but in the other cases I don't see any possible improvement.

I introduced the plans especially because they make bootstrapping much more efficient and reliable, as you're sure that you didn't miss any option. If the signal is different you need to perform a whole new periodogram anyway.

giordano avatar Jun 02 '20 16:06 giordano