Open a-z-e-r-i-l-a opened 4 years ago
The purpose of the NFFT is to solve the two equations listed here in O[N log M]
time rather than the naive O[N M]
time.
I suspect you can probably map what you want to do onto these two equations, with a bit of effort. At that point, you could use the NFFT to do it faster.
Thought about this a bit - the real issue is that the NFFT constructs a Fourier basis based on a fundamental frequency that is related to the extent of the data, and in your case there is no guarantee that this fundamental frequency matches the fundamental frequency of your model. So if you want to do this kind of extrapolation, you'll first have to determine the fundamental frequency on which to construct your Fourier basis.
One way to do this is via a least-squares fitting of a likelihood function minimized over frequency; this can be expressed in terms of the nfft, but simply putting your data into an NFFT won't be much help. One possible approach for this is a Lomb-Scargle periodogram, which is implemented in astropy: https://docs.astropy.org/en/stable/timeseries/lombscargle.html (it's implemented using something very similar to an NFFT, but provides the high-level interface you're looking for).
So to construct your inference model, I would start with that, find the best-fit frequency (subject to the caveats listed there) and then use the model()
method to build your frequency model.
So why isn't this as easy as just computing the FFT as in the uniformly-sampled case? Well, for uniformly sampled data, you can only detect frequencies that are an integer multiple of the data baseline, for reasons you can read about in any FFT theory handbook. For unevenly spaced data, your data can constrain virtually any frequency, so you have to be more careful.
Hope that helps.
@jakevdp Yes, that completely worked for what I was looking for! Thank you!!
Hi,
I did an experiment with the output of the nfft which I was not sure how to interpret it. First I calculate the nfft_adjoint and then based on the output try to reconstruct the result which works.
It is also the same output if I use the original forward fft.
My expectation was to see also the same wave continue osculating outside the data range the adjoing nfft was calculated on it.
Isn't the purpose of nfft finding the true frequency components of a signal similar to fft, or have I been using it incorrectly.
my data is in addition as follows:
Thanks.