Skip to content

Instantly share code, notes, and snippets.

@jameslyons
Last active January 18, 2016 08:39
Show Gist options
  • Save jameslyons/8817385 to your computer and use it in GitHub Desktop.
Save jameslyons/8817385 to your computer and use it in GitHub Desktop.
Modified covariance method (a.k.a forward-backward method) of LPC calculation
function armcov(x,L)
N = length(x)
phi = zeros(L+1,L+1)
for k = 0:L, i=0:L, n=0:N-L-1
phi[k+1,i+1] += x[n+1+k]*x[n+1+i] + x[n+1+L-k]*x[n+1+L-i]
end
phi = phi./(2*(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 = armcov(x,5)
print(a)
print(P)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment