Why does this 1-D array in python get altered / re-defined while being autocorrelated? -


in python, have 1 1-d array coef defined follows:

coef = np.ones(frame_num-1)  in range(1,frame_num):     coef[i-1] = np.corrcoef(data[:,i],data[:,i-1])[0,1]  np.savetxt('serial_corr_results/coef_rest.txt', coef) 

now want autocorrelation on it, , use code posted deltap in post:

timeseries = (coef) #mean = np.mean(timeseries) timeseries -= np.mean(timeseries) autocorr_f = np.correlate(timeseries, timeseries, mode='full') temp = autocorr_f[autocorr_f.size/2:]/autocorr_f[autocorr_f.size/2] 

the autocorrelation works fine, however, when want plot or work original coef, values have changed of timeseries -= np.mean(timeseries).

why original array coef changed here , how can prevent being altered? need further down in script other operations.

also, operation -= doing? have tried google that, haven't found it. thanks!

numpy arrays mutable, e.g.

timeseries = coef           # timeseries , coef point same data timeseries[:] = 0 

will set both timeseries , coef zero.

if do

timeseries = coef.copy()    # timeseries copy of coef own data timeseries[:] = 0 

instead, coef remain untouched.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -