如果 numpy.correlate 与 scipy.signal.correlate 都用于一维数组,它们是否不同?

Does numpy.correlate differ from scipy.signal.correlate if both are used on a 1D array?

scipy的相关函数的文档声称它可以用于N维数组

scipy.signal.correlate(in1, in2, mode='full', method='auto')

Cross-correlate two N-dimensional arrays. Cross-correlate in1 and in2, with the output size determined by the mode Argument.

而 numpy 的关联只能用于一维序列。

numpy.correlate(a, v, mode='valid')

Cross-correlation of two 1-dimensional sequences. This function computes the correlation as generally defined in signal processing texts:

c_{av}[k] = sum_n a[n+k] * conj(v[n])

with a and v sequences being zero-padded where necessary and conj being the conjugate.

如果这两个函数都用于两个一维数组,那么这些函数有什么不同吗?如果不是,numpy.correlate 的用例是什么?

scipy 实现在某些情况下会调用 numpy 版本,但在可能更快时也会使用更快的基于 FFT 的实现。有关详细信息,请参阅 choose_conv_method or the source

这个 "duplication" 是为了让 numpy 可以提供一个优化的函数基础,通常由 scipy 扩展以提供更完整的功能覆盖(通常不太优化,但仍然主要是原生的代码非常快并且数值稳定)。这种明显重复的其他示例是线性代数功能(linalg 包)和傅里叶变换(其中 numpy 提供了一些有限的功能,scipy 导出了大部分 fftpack