Skip to content

Instantly share code, notes, and snippets.

@tuxzz
Forked from jameslyons/arcov.jl
Created January 18, 2016 08:39
Show Gist options
  • Save tuxzz/fd5c59d5ba46a35331b7 to your computer and use it in GitHub Desktop.
Save tuxzz/fd5c59d5ba46a35331b7 to your computer and use it in GitHub Desktop.
covariance method of LPC calculation
function arcov(x,L)
N = length(x)
phi = zeros(L+1,L+1)
for k = 0:L, i=0:L, n=L:N-1
phi[k+1,i+1] += x[n+1-k]*x[n+1-i]
end
phi = phi./(N-L)
a = phi[2:end,2:end]\-phi[2:end,1]
P = phi[1,1] + phi[1,2:end]*a
[1,a],P
end
x =[1:10,10:-1:1]
a,P = arcov(x,5)
print(a)
print(P)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment