-
Notifications
You must be signed in to change notification settings - Fork 5
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
Autoregressive prewhitening (per channel) #60
Comments
To Do this practically we need:
|
This approach, and prewhitening in general can be applied either to the whole time series before windowing/detrending, or after windowing it can be applied in a "window-by-window" way. Obviously for first (or second) difference there should be little if any difference, but when the prewhitening involves fitting a statistical model, this choice of when along the pipeline to apply this transformation matters, i.e. we expect slightly different ARMA coefficients for each window, and moreover, these window-by-window fits will differ from the ARMA coefficients that wouls be obtained if we fit a model to the entire time series. In general the pipeline should be modified to give the user the option (via config) of when to apply prewhitening
|
I took a crack at this on the fix_issue_60 branch, but it was not trivial. ToDo:
|
Created a jupyter notebook called arma_primer.ipynb which shows how to use statsmodels package to fit an arma model and handle a few gory details. At this point I am satified that given an arbitrary time series we can prewhiten it with ARMA, then FFT and then compensate for the ARMA coefficients on the frequency domain side. The following need to be addressed: Note: this ticket is about adding prewhitening per channel, but there has been no statement yet about whether the operation happens within a channel "per-window" or "per time series". Discussions with Gary hinted that "we may as well" just fit to the entire time series, but those discussions predated observations that the time series can get very (very) long ... i.e. larger than RAM in some cases. Because of this, I think we need to specify a prewhitening window length. The default window lengths can be either "whole time series", or "fft window" ... anything else will wind up being complicated, for what are likely diminishing returns. Ultimately, I had hoped to show that ARMA PW on the "whole run" would yield PW quality around the same as if we had applied it "per FFT window", because in that case, I had hoped to deprecate the intrinsic windowing code and just use the built-in spectrogram method of scipy.signal. However ... showing this, in any sort of definitive way seems like a study on it's own, and is in some sense beyond the scope of the current aurora objectives. So I think we want to
Finally, consider that once the time series is decomposed into white noise and an ARMA filter, the FFT of the ARMA filter is still being transformed in the ipynb with scipy.signal.freqz, which calls fft under the hood ... aren't we subject to leakage from that transformation? If so, how do we know it is less severe than fft without the ARMA decomposition? Empirically it looks like there is less leakage (high frequencies of the spectra have lower amplitudes) but it isn't obvious (to me) how exactly the leakage is being mitigated, nor by how much. |
-it works for low order MA, but not for ARMA(2,3) for example Issue(s): #60
THese are incomplete and I had intended to merge them all toghether, but after noticing the bug in arma_primar, I want to get an archived copy of primer4. Primer4 doesn't suffer infinitely lfilter response because the time series is only 1024 points, not 2048 [Issue(s): #60]
First difference prewhitening mitigated most of the spectral leakage artefacts in the synthetic test dataset. Gary suggested that we add autoregressive prewhitening as well, say to order 3 or 4. This would be implemented per channel, and thus would need to recolored.
This is a different issue than Gary's segment-by-segment prewhitening from the original FORTRAN codes, which is a seperate issue but can be implemented (see issue #3 for some details)
The text was updated successfully, but these errors were encountered: