0

In my code I am using scipy.signal.correlate with 1D arrays but it gives me a different result on Windows 11 and on Ubuntu.

The Linux's result should be the right one, since, after some further calculations, it is realistic.

Following the path of the variables it seems that the culprit is multiarray.correlate, since the value of all the variables is equal for the 2 OSs until that call in numeric.py

Some specifications: it uses mode full and method auto, it ends up using the method direct and so, calling np.convolve and then multiarray.correlate.

Why is this happening and how can I get the same result across OSs?

jared
  • 4,165
  • 1
  • 8
  • 31
albertopasqualetto
  • 87
  • 1
  • 1
  • 11

1 Answers1

0

The problem is not directly related to scipy.signal.correlate or multiarray.correlate, but the fact is that in Windows numpy uses numpy.int32, instead, in linux it chooses correctly the type based on the architecture and, in this case, it chooses numpy.int64. This leds to an overflow during the calculation of cross-correlation.

Pay attention that this is not written in numpy's documentation.

Sources:

https://github.com/numpy/numpy/issues/9464

numpy array dtype is coming as int32 by default in a windows 10 64 bit machine

albertopasqualetto
  • 87
  • 1
  • 1
  • 11