Re: [Numpy-discussion] Problem with correlate
I wonder if xcorrelate would be a better name than acorrelate? I think it would. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Problem with correlate
I also think that the conjugate should be taken. I spent the last few weeks using correlate to experiment with signal processing and I got strange results until I realised that I had to manually take the conjugate. It would also be good if the function did it since applying the conjugate to the wrong sequence yields the complex conjugate of the correlation. Who would want to use the correlation without the conjugate, if someone is only using real values it won't affect them, if they are using complex values they probably want to conjugate. One function that does depend on correlate though is convolution! Changes made to correlate will affect it! but I have understand that a new function acorrelate is being created instead of changing correlate? Otherwise I've never used matlab but it does seem like xcorr has some good features. The modes 'same' and 'valid' were initially quite confusing especially as the default is 'valid', meaning that autocorrelations lead to a single value by default! I also think that having weighting options would be good. I now understand the complexities of the various weightings that can be applied to the correlation i.e. biased vs unbiased but I think that having correlate include these options might prompt users to investigate which one they really needed. Correlate seemed so simple when I first used it but it took me ages to realise that these are choices to be made. regards Rob ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Problem with correlate
Hi, After my previous email, I have opened a ticket #1117 (correlate not order dependent) I have found that the correlate function is defined in multiarraymodule.c and that inputs are being swapped using the following code n1 = ap1-dimensions[0]; n2 = ap2-dimensions[0]; if (n1 n2) { ret = ap1; ap1 = ap2; ap2 = ret; ret = NULL; i = n1; n1 = n2; n2 = i; } I do not know the code well enough to see whether this could just be removed (I don't know c either). Maybe the algorithmn requires the inputs to be length ordered? I will try to work it out. Regards Rob ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Problem with correlate
Hi all, I have been using numpy.correlate and was finding something weird. I now think that there might be a bug. Correlations should be order dependent eg. correlate(x,y) != correlate(y,x) in general (whereas convolutions are symmetric) import numpy as N x = N.array([1,0,0]) y = N.array([0,0,1]) N.correlate(x,y,'full') array([1, 0, 0, 0, 0]) N.correlate(y,x,'full') array([0, 0, 0, 0, 1]) This works fine. However, if the arrays have different lengths, we get a problem. y2=N.array([0,0,0,1]) N.correlate(x,y2,'full') array([0, 0, 0, 0, 0, 1]) N.correlate(y2,x,'full') array([0, 0, 0, 0, 0, 1]) I believe that somewhere in the code, the arrays are re-ordered by their length. Initially I thought that this was because correlate was deriving from convolution but looking at numpy.core, I can see that in fact convolution derives from correlate. After that, it becomes C code which I haven't managed to look at yet. Am I correct, is this a bug? regards Rob Steed ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion