python中自相关函数的正确编码

2024-10-03 15:22:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我有两个数据集,每个数据集有325个元素长。一个是沿X轴的数据,一个是沿y轴的数据。Q[0]和Q[1]一起构成Q

方程式应该是这样的:

(Q(i+deltai,j)-均值(Q\u i,j))x(Q\u i,j-均值(Q\u i,j))/(Q\u i,j-均值(Q\u i,j))^2

这是一个自相关函数。我想对第一个函数遍历I+delta I,同时遍历Q中的数据np.关联. 最后,我觉得自己对python还不太熟悉,觉得自己在过去的几天里一直在追赶自己的尾巴。你知道吗

我试过的代码是:

I = npzfile['i']
Q = npzfile['q']
U = npzfile['u']

nxside = Q.shape[0]
nyside = Q.shape[1]

for i in numpy.arange(0,nxside-1,1):
     result = numpy.correlate(Q[0], Q, mode='full')
     result2 = (result/float(result.max()))
     plt.plot(result2, '-')

 for i in numpy.arange(0,nxside-1,1):
     for j in numpy.arange(0, nyside-1,1):

# #       # J= (i)
# #       # # L = ()
# #       # # print L
     M = (Q - numpy.mean(Q))
     B = (Q[i] - numpy.mean(Q))
     K = (Q - numpy.mean(Q))**2
     Z = numpy.abs(M*B)/numpy.abs(K)
#    print numpy.abs((M*B)/K)
     plt.plot(Z, 'ro')

我希望输出是在y轴上0到1之间变化的,超过325个元素。你知道吗


Tags: 数据函数innumpy元素forabsresult