SDFT¶
Sliding Discrete Fourier Transform (SDFT).
Initially, the coefficients are all equal to 0, up until enough values have been seen. A call to numpy.fft.fft
is triggered once window_size
values have been seen. Subsequent values will update the coefficients online. This is much faster than recomputing an FFT from scratch for every new value.
Parameters¶
-
window_size
The size of the window.
Attributes¶
-
window (utils.Window)
The window of values.
Examples¶
>>> from river import utils
>>> X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> window_size = 5
>>> sdft = utils.SDFT(window_size)
>>> for i, x in enumerate(X):
... sdft = sdft.update(x)
...
... if i + 1 >= window_size:
... assert np.allclose(sdft, np.fft.fft(X[i+1 - window_size:i+1]))