-
-
Save tuxzz/578ca2eca98639b9bb17 to your computer and use it in GitHub Desktop.
Modified covariance method (a.k.a forward-backward method) of LPC calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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