Hi all,
I have an open numpy PR (#31261) that adds maxlag and lags keyword parameters to np.correlate and np.convolve, allowing users to compute correlation/convolution at only a subset of lags rather than the full set. The motivation for this feature is that there are great performance improvements when the set of lags of interest is much smaller than the set of lags corresponding to any of the existing modes, as is frequently the case when analyzing long time series. There is also a new companion function np.correlation_lags() analogous to scipy.signal.correlation_lags() to allow a user to generate an array of the lags that correspond to the cross-correlation/convolution they calculated.
Matplotlib currently has a maxlags parameter on its xcorr() function, which calls np.correlate(). The matplotlib implementation calculates the full cross-correlation at all lags and then returns the relevant lags. So if this gets included in numpy, matplotlib can call the np.correlate() function with the new maxlag parameter to get the appropriate result with a huge performance improvement.
Two questions:
- Would this functionality in numpy be of interest to matplotlib? Would you like a PR to use the new function keyword if it gets merged in numpy?
maxlagseems like a more appropriate name for this parameter in the numpy function thanmaxlagssince it is a scalar value, and since it will be paired with alagsparameter that will actually be an array-like value. Does that difference of terminology bother you, as long as it is explicitly documented?
Looking forward to your thoughts,
Honi