[Numpy-discussion] Bug in numpy.correlate documentation

Richard Hattersley rhattersley at gmail.com
Tue Oct 8 15:10:41 EDT 2013


Hi Bernard,

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.

Regards,
Richard Hattersley


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 [1]: a = [1, 2]
>
> In [2]: v = [2, 1j]
>
> In [3]: z = correlate(a, v, 'full')
>
> In [4]: z
> Out[4]: array([ 0.-1.j,  2.-2.j,  4.+0.j])
>
> However, according to the documentation, z should be
>
>         z[-1] = a[1] * conj(v[0]) = 4.+0.j
>         z[0]  = a[0] * conj(v[0]) + a[1] * conj(v[1]) = 2.-2.j
>         z[1] = a[0] * conj(v[1]) = 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])
>
> Cheers,
>         Bernhard
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131008/03529007/attachment.html>


More information about the NumPy-Discussion mailing list