Open
Description
To compute the cross correlation at lag p of two 1D arrays of length n
you compute sum(x(1+p:n)*y(1:n-p))
. If you want the cross correlation at all lags, the Fast Fourier Transform can be used to speed the calculation. Intel describes Implementing the Fourier Correlation Algorithm Using oneAPI. I suggest adding a function ccf(x,y,p)
which computes cross correlations from lags 0 to p and uses an FFT when that is the fastest method (which will be for large p).
In general, linear time series analysis and signal processing could be part of stdlib.