# Linear Prediction Coefficients

I want to learn how to compute linear coefficient, but to be honest - I can't. I know how to use them if i have it and why I want them.

Suppose this toy example:

A signal $x=[-1, -2, 0, 1]$

According to matlab function lpc(X,p) if I want to compute the 2th order coefficients of this signal the result is $a = [1.0, -0.50, 0.50]$ and $g=1.0$

I Know how to compute the g using $A(k)$ formula and that $a_0=1$ always, but can someone explain me why $a_1=-0.5, a_2=0.5$ how to compute them without using matlab or any other software.

P.S It there any method which allow me using $A(k)$ to compute directly the coefficients?

thanks

First you need to compute the signal's autocorrelation:

$$R(k)=\sum_nx(n)x(n+k),\quad k=0,1,\ldots,p$$

In your case with $p=2$ you get

\begin{align}R(0)&=(-1)(-1)+(-2)(-2)+0\cdot 0+1\cdot 1=6\\ R(1)&=(-1)(-2)+(-2)\cdot 0+0\cdot 1=2\\ R(2)&=(-1)\cdot 0+(-2)\cdot 1=-2\end{align}

Then you have to solve a system of linear equations:

$$\begin{bmatrix}R(0)&R(1)\\ R(1)&R(0)\\ \end{bmatrix} \begin{bmatrix}a_1\\a_2\end{bmatrix}= -\begin{bmatrix}R(1)\\R(2)\end{bmatrix}$$

which gives the values $a_1=-0.5$ and $a_2=0.5$. Of course $a_0=1$, as you've already noted.

The matrix that occurs in the system of linear equations is a Toeplitz matrix, i.e. all its diagonals have the same elements. As a result, such systems can be solved by specialized and efficient algorithms, such as Levinson's algorithm.

• I get it. One more question: the $A(k)= \frac{1}{N} \sum_{ k}^{N-1}\left \|x(n)-x(n-1) \right \|$ which I compute (matlab called it $g$)what exactly is(are you use it?) and what's your method name? – Eric P. Jun 14 '15 at 12:04
• @EricP.: I just used the definition of the LPC coefficients; that's not really a "method". The various methods usually differ in the way they solve the system of equations. As mentioned in my answer, one popular method is Levinson's algorithm. The value $g$ is the variance of the prediction error, and it can be computed as $R_0+a_1R_1+a_2R_2=4$ (so it's not $1$). – Matt L. Jun 14 '15 at 13:50
• Matt L. for the above signal $X=[-1, -2 ,0,1]$ if you press $[a,g] = lpc(X,2)$ as the result you get $g=1.0$ – Eric P. Jun 14 '15 at 14:11
• @EricP.: OK, then you have to figure out what Matlab means by $g$, it can't be the error variance then. – Matt L. Jun 14 '15 at 14:38
• According to mathworks site, $g$ is the prediction error variance. link – Eric P. Jun 14 '15 at 14:52