# autocorrelation A to K conversion for LPC speech analysis?

I am building an LPC analysis tool for speech synthesis and did the following to generate my a0 through a10:

sum = 0
for (i = 0; i < N - order; i++) {
sum += s[i + order] * s[i]
}


So, for an example sequence:

s[0]: -0.00036988587817177176
s[1]: -0.0005228677182458341
s[2]: -0.002549876691773534
s[3]: -0.005284426733851433
s[4]: 0.03419444337487221
s[5]: 0.06330401450395584
s[6]: 0.2461005449295044
s[7]: 0.36327624320983887
s[8]: 0.5022943019866943
s[9]: 0.7432577013969421
s[10]: 0.7451401948928833
s[11]: 0.9017787575721741
s[12]: 0.9144688248634338
s[13]: 0.8055802583694458
s[14]: 0.7247466444969177
s[15]: 0.5342929363250732


I get:

a0: 1.6765472891346052
a1: 1.5827508756328967
a2: 1.3697197839567066
a3: 1.0687599069050433
a4: 0.741864438363822
a5: 0.4665998816936655
a6: 0.2567268139253708
a7: 0.12122018661739875
a8: 0.04979388551368519
a9: 0.016472847413864372
a10: 0.003187118053062932


and then when I run that through my K conversion, I get:

k1: -0.9440538217385303
k2: 0.6826731774147582
k3: 0.27304617789929586
k4: -0.18255947440809286
k5: -0.48868909366775654
k6: 0.1881875661845312
k7: 0.3690787060329103
k8: -0.005584315353450492
k9: -0.3649987110269231
k10: -0.03950634100447886


I have another LPC analysis tool which shows totally different K values than what I am getting, so I am suspecting that my code to generate the a's has an error in it.

I've been looking online for something that can say, given this A, its K should be: X... But I have not been able to find any such thing.

Can anyone here verify that my As and Ks are correct, given this example sequence?

After applying a Hamming window to your data I get very similar autocorrelation values:

R =
1.6765e+00
1.5828e+00
1.3697e+00
1.0688e+00
7.4186e-01
4.6660e-01
2.5672e-01
1.2121e-01
4.9779e-02
1.6453e-02
3.1701e-03



You can check your LPC filter coefficients (not the reflection coefficients) by computing the matrix-vector product $\mathbf{R}\mathbf{a}$ where $\mathbf{a}$ is the vector of LPC coefficients and $\mathbf{R}$ is a Toeplitz matrix with the autocorrelation values:

$$\mathbf{R}=\begin{bmatrix}R(0)&R(1)&\ldots && R(p)\\ R(1)&R(0)&R(1)&\ldots&R(p-1)\\ \vdots& & \ddots & &\vdots\\ R(p) & R(p-1) & \ldots && R(0)\end{bmatrix}$$

This product must result in a vector with the first element being non-zero, and all the other elements must be zero (up to numerical accuracy).

Using the Octave function [lpc,v,k]=levinson(R(1:11)); with the autocorrelation function given above, I get the following LPC filter coefficients:

lpc =

1.000000
-1.370890
-0.386146
0.813691
0.992372
-0.949576
-0.642884
0.427407
0.515102
-0.310107
-0.039544


And these are the corresponding reflection coefficients:

k =

-0.9440538
0.6826730
0.2730461
-0.1825513
-0.4886926
0.1882461
0.3690086
-0.0056205
-0.3648883
-0.0395440


So we get very similar values from which you can conclude that your code for computing the reflection coefficients from the autocorrelation function is correct.

• I am sorry-- I some how forgot to mention that I am applying a hamming window to the signal, and that's why the As are so different than what you show... If I turn off my hamming window then the a0 I get is: 4.666856304718674, and the a10 I get is: 0.051544872290064506... The a10 is still a little different than what you show, but very close. Commented Jan 16, 2015 at 18:05
• @patrick: OK, with the Hamming window our values are very similar, so I guess your code is OK (see updated answer). Commented Jan 17, 2015 at 8:48