Skip to content

Instantly share code, notes, and snippets.

@tuxzz
Forked from jameslyons/arburg.jl
Created January 18, 2016 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxzz/f737be91d46d5534ad47 to your computer and use it in GitHub Desktop.
Save tuxzz/f737be91d46d5534ad47 to your computer and use it in GitHub Desktop.
burg method of LPC computation
function arburg(x,p)
N = length(x)
P = zeros(1,p+1)
f = zeros(p+1,N)
b = zeros(p+1,N)
a = zeros(p,p)
# Initialisation
f[1,:] = x
b[1,:] = x
P[1] = var(x)
for m = 1:p
numer,denom = 0,0
for n=0:N-m-1
numer += b[m,n+1]*f[m,n+2]
denom += f[m,n+2]^2 + b[m,n+1]^2
end
a[m,m] = -2*numer/denom
for i = 1:m-1
a[m,i] = a[m-1,i] + a[m,m]*a[m-1,m-i]
end
P[m+1] = P[m]*(1-a[m,m]^2)
for n=0:N-m-1
f[m+1,n+1] = f[m,n+2] + a[m,m]*b[m,n+1]
b[m+1,n+1] = b[m,n+1] + a[m,m]*f[m,n+2]
end
end
[1 a[p,:]], P[p]
end
p = 5
x = [1:10,10:-1:1]
a,P = arburg(x,p)
print(a)
print(P)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment