[Numpy-discussion] Bug in numpy.correlate documentation
rhattersley at gmail.com
Tue Oct 8 15:10:41 EDT 2013
Looks like you're on to something - two other people have raised this
discrepancy before: https://github.com/numpy/numpy/issues/2588.
Unfortunately, when it comes to resolving the discrepancy one of the
previous comments takes the opposite view. Namely, that the docstring is
correct and the code is wrong.
Do different domains use different conventions here? Are there some
references to back up one stance or another?
But all else being equal, I'm guessing there'll be far more appetite for
updating the documentation than the code.
On 7 October 2013 22:09, Bernhard Spinnler <Bernhard.Spinnler at gmx.net>wrote:
> The numpy.correlate documentation says:
> correlate(a, v) = z[k] = sum_n a[n] * conj(v[n+k])
> In : a = [1, 2]
> In : v = [2, 1j]
> In : z = correlate(a, v, 'full')
> In : z
> Out: array([ 0.-1.j, 2.-2.j, 4.+0.j])
> However, according to the documentation, z should be
> z[-1] = a * conj(v) = 4.+0.j
> z = a * conj(v) + a * conj(v) = 2.-2.j
> z = a * conj(v) = 0.-1.j
> which is the time reversed version of what correlate() calculates.
> IMHO, the correlate() code is correct. The correct formula in the docs
> (which is also the correlation formula in standard text books) should be
> z[k] = sum_n a[n+k] * conj(v[n])
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion