
Hi All, after the discussion on numpy.correlate some time ago, regarding complex conjugation, etc. I today was pointed to yet another oddity, which I hope somebody could explain to me, as to why that's a feature, rather than a bug. I'm thoroughly confused by the following behaviour: In [29]: x = array([0.,0.,1, 0, 0]) In [30]: y = array([0, 0, 0, 1., 0, 0, 0]) In [31]: correlate(x,y) Out[31]: array([ 0., 1., 0.]) In [32]: correlate(x,y, mode='full') Out[32]: array([ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]) In [33]: y = array([0,0,1.,0,0]) In [34]: correlate(x,y,mode='full') Out[34]: array([ 0., 0., 0., 0., 1., 0., 0., 0., 0.]) So far, everything is allright and as expected. Now: In [35]: y1 = array([1,0,0,0,0]) In [36]: correlate(x,y1,mode='full') Out[36]: array([ 0., 0., 0., 0., 0., 0., 1., 0., 0.]) In [37]: y2 = array([1,0,0,0,0,0,0]) In [38]: correlate(x,y2,mode='full') Out[38]: array([ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]) Could somebody please help me understanding, why the one switches places? Furthermore, this behaviour does not seem to be very consistent, if we switch the x and y argument: In [39]: correlate(y2,x,mode='full') Out[39]: array([ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]) In [40]: correlate(y1,x,mode='full') Out[40]: array([ 0., 0., 1., 0., 0., 0., 0., 0., 0.]) The answer remains the same. Any help would be appreciated, the numpy version is 1.0.4. Best regards, Hanno -- Hanno Klemm klemm@phys.ethz.ch

2008/8/20 Hanno Klemm <klemm@phys.ethz.ch>:
In [29]: x = array([0.,0.,1, 0, 0]) In [35]: y1 = array([1,0,0,0,0])
In [36]: correlate(x,y1,mode='full') Out[36]: array([ 0., 0., 0., 0., 0., 0., 1., 0., 0.])
That doesn't look right. Under r5661: In [60]: np.convolve([0, 0, 1, 0, 0], [1, 0, 0, 0, 0], mode='f') Out[60]: array([0, 0, 1, 0, 0, 0, 0, 0, 0]) Regards Stéfan

------=_Part_25307_10322093.1219268954678 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
2008/8/20 Hanno Klemm <klemm@phys.ethz.ch>:
In [29]: x =3D array([0.,0.,1, 0, 0]) In [35]: y1 =3D array([1,0,0,0,0])
In [36]: correlate(x,y1,mode=3D'full') Out[36]: array([ 0., 0., 0., 0., 0., 0., 1., 0., 0.])
That doesn't look right. Under r5661:
In [60]: np.convolve([0, 0, 1, 0, 0], [1, 0, 0, 0, 0], mode=3D'f') Out[60]: array([0, 0, 1, 0, 0, 0, 0, 0, 0])
Regards St=E9fan
------=_Part_25307_10322093.1219268954678 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
<div dir=3D"ltr">2008/8/20 Hanno Klemm <<a
Hi Stefan, yes, indeed, that's what I thought. This result is odd. Has correlate been changed since version 1.0.4, or should I submit this as a bug? Best regards, Hanno Stéfan van der Walt <stefan@sun.ac.za> said: href=3D"mailto:klemm@phys.eth=
z.ch">klemm@phys.ethz.ch</a>>:<br>> In [29]: x =3D array([0.,0.,1, 0,= 0])<br>> In [35]: y1 =3D array([1,0,0,0,0])<br>><br>> In [36]: co= rrelate(x,y1,mode=3D'full')<br> > Out[36]: array([ 0., 0., 0., 0., 0., 0.,= 1., 0., 0.])<br><br>That doesn't look right. U= nder r5661:<br><br>In [60]: np.convolve([0, 0, 1, 0, 0], [1, 0, 0, 0, 0], m= ode=3D'f')<br>Out[60]: array([0, 0, 1, 0, 0, 0, 0, 0, 0])<br> <br>Regards<br>St=E9fan<br><br></div>
------=_Part_25307_10322093.1219268954678--
-- Hanno Klemm klemm@phys.ethz.ch

Hi Hanno 2008/8/22 Hanno Klemm <klemm@phys.ethz.ch>:
yes, indeed, that's what I thought. This result is odd. Has correlate been changed since version 1.0.4, or should I submit this as a bug?
Is there any way that you could try out the latest release on your machine and see if it solves your problem? We probably won't be releasing bug-fixes on 1.0.4, but if it exists in 1.1 we'll still address it. I'm not aware of any changes, but I may simply have missed it. Regards Stéfan

Hi Stefan, I checked it with numpy version 1.1.1 just now and the result is the same:
x = N.array([0.,0,1,0,0]) y1 = N.array([1.,0,0,0,0]) N.correlate(x,y1, mode='full') array([ 0., 0., 0., 0., 0., 0., 1., 0., 0.]) y2 = N.array([1.,0,0,0,0,0,0]) N.correlate(x,y2, mode='full') array([ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]) N.__version__ '1.1.1'
Best regards, Hanno Stéfan van der Walt <stefan@sun.ac.za> said:
Hi Hanno
2008/8/22 Hanno Klemm <klemm@phys.ethz.ch>:
yes, indeed, that's what I thought. This result is odd. Has correlate been changed since version 1.0.4, or should I submit this as a bug?
Is there any way that you could try out the latest release on your machine and see if it solves your problem? We probably won't be releasing bug-fixes on 1.0.4, but if it exists in 1.1 we'll still address it. I'm not aware of any changes, but I may simply have missed it.
Regards Stéfan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- Hanno Klemm klemm@phys.ethz.ch
participants (2)
-
Hanno Klemm
-
Stéfan van der Walt