I have a equation of autocorrelation matrix with lag needed for lpc analysis:
I wrote methods:
def autocorr_matrix(x,order):
R = numpy.zeros((order, order))
for i in range(0,order):
for j in range(0,order):
R[i,j] = autocorrelate(x, abs(i-j))
return R
def autocorrelate(x,lag):
return numpy.correlate(x[0:len(x)-lag],x[lag:len(x)])
is it correct solution? Anybody have idea how can i test results of these methods?
To test your results you can use two methods:
1- Create two sin signals with phase shift and see whether your code can measure the correlation or not.
2- Use some trustable libraries for correlation and check your results. the library I'm using is 'statsmodel': statsmodel.org
from statsmodels.tsa.stattools import acf,ccf
acf is for autocorrelation and ccf is for cross-correlation.