# LPC spectra estimate

Started by February 6, 2009
```I plot LPC spectra with matlab. The LPC spectra keep the same shape
with the envelope of DFT spectra.

But it is larger with a offset than the DFT envelope.

Why? Where it go wrong?

Here is the matlab script which illustrate it.

N = 2560;
[x,fs] = wavread('lpc.wav',N); % any speech signal can be used

p=12;
a = lpc(x,p);

X =fft(x);
X = X(1:N/2+1)';
X = 10*log10(abs(X).^2);

Z = fft(a,N);
Z = 1./Z(1:N/2+1);
Z = 10*log10(abs(Z).^2);

figure;
plot(X');
hold on;
plot(Z,'r');
grid;
offset = 10;
figure;
plot(X+offset);
hold on;
plot(Z,'r');
grid;
```
```On 6 Feb, 08:42, hyeewang <hyeew...@gmail.com> wrote:
> I plot LPC spectra with matlab. The LPC spectra keep the same shape
> with the envelope of DFT spectra.

If you look at the normal equations you'll find that the
information about the signal is divided into two separate
parts:

- The prediction coefficients
- The prediction variance sigma^2

The prediction coefficients represent the shape of the
spectrum while the prediction variance represents the
energy of the signal.

Try to scale the spectrum by either sigma^2 or or 1/sigma^2
and see if the results are better.

Rune
```
```On 2&#2013265940;&#2013265922;6&#2013265928;&#2013265941;,
&#2013265935;&#2013265922;&#2013265934;&#2013265927;4&#689;52&#2013266103;&#2013265942;,
Rune Allnor <all...@tele.ntnu.no> wrote:
> On 6 Feb, 08:42, hyeewang <hyeew...@gmail.com> wrote:
>
> > I plot LPC spectra with matlab. The LPC spectra keep the same shape
> > with the envelope of DFT spectra.
>
> If you look at the normal equations you'll find that the
> information about the signal is divided into two separate
> parts:
>
> - The prediction coefficients
> - The prediction variance sigma^2
>
> The prediction coefficients represent the shape of the
> spectrum while the prediction variance represents the
> energy of the signal.
>
> Try to scale the spectrum by either sigma^2 or or 1/sigma^2
> and see if the results are better.
>
> Rune

Thank you. Rune.

LPC function in matlab return LPC coefficients and prediction error
variance sigma^2. How to attain

signal variance from prediction error variance?

Mulitiply the spetrua by either sigma^2 or  1/sigma^2 can not make  a
better spectrua view.
Mulitiply the spetrua by either sigma or  1/sigma can not make  a
better spectrua view.

How to achieve the scale factor exactly?

Cheers
```
```>On 6 Feb, 08:42, hyeewang <hyeew...@gmail.com> wrote:
>> I plot LPC spectra with matlab. The LPC spectra keep the same shape
>> with the envelope of DFT spectra.
>
>If you look at the normal equations you'll find that the
>information about the signal is divided into two separate
>parts:
>
>- The prediction coefficients
>- The prediction variance sigma^2
>
>The prediction coefficients represent the shape of the
>spectrum while the prediction variance represents the
>energy of the signal.
>
>Try to scale the spectrum by either sigma^2 or or 1/sigma^2
>and see if the results are better.
>
>Rune
>

Thank you. Rune.

LPC function in matlab return LPC coefficients and prediction error
variance sigma^2. How to attain

signal variance from prediction error variance?

Mulitiply the spetrua by either sigma^2 or  1/sigma^2 can not make  a
better spectrua view.
Mulitiply the spetrua by either sigma or  1/sigma can not make  a better
spectrua view.

How to achive the scale factor exactly?

Cheers

HyeeWang

```
```On 2&#2013265940;&#2013265922;8&#2013265928;&#2013265941;,
&#2013265929;&#2013265935;&#2013265934;&#2013265927;5&#689;00&#2013266103;&#2013265942;,
"hyeewang" <hyeew...@yahoo.com.cn> wrote:
> >On 6 Feb, 08:42, hyeewang <hyeew...@gmail.com> wrote:
> >> I plot LPC spectra with matlab. The LPC spectra keep the same shape
> >> with the envelope of DFT spectra.
>
> >If you look at the normal equations you'll find that the
> >information about the signal is divided into two separate
> >parts:
>
> >- The prediction coefficients
> >- The prediction variance sigma^2
>
> >The prediction coefficients represent the shape of the
> >spectrum while the prediction variance represents the
> >energy of the signal.
>
> >Try to scale the spectrum by either sigma^2 or or 1/sigma^2
> >and see if the results are better.
>
> >Rune
>
> Thank you. Rune.
>
> LPC function in matlab return LPC coefficients and prediction error
> variance sigma^2. How to attain
>
> signal variance from prediction error variance?
>
> Mulitiply the spetrua by either sigma^2 or  1/sigma^2 can not make  a
> better spectrua view.
> Mulitiply the spetrua by either sigma or  1/sigma can not make  a better
> spectrua view.
>
> How to achive the scale factor exactly?
>
> Cheers
>
> HyeeWang-
&#2013265938;&#2013266174;&#2013266098;&#1585;&#2013266107;&#2013265938;&#2013266173;&#2013265939;&#2013265923;&#2013265934;&#2013265924;&#2013265943;&#2013265942;
-
>
> -
&#2013265935;&#2013265940;&#702;&#2013265938;&#2013266173;&#2013265939;&otilde;&#2013265924;&#2013265934;&#2013265924;&#2013265943;&#2013265942;
-

Mulitiply the spectra by either sigma^2 or  1/sigma^2 can not make  a
better spectra view.
Mulitiply the spectra by either sigma or  1/sigma can not make  a
better
spectra view.

Here is the matlab script.

Puzzle.

N = 2560;
[x,fs] = wavread('origsign.wav',N); % any speech signal can be used

p= 12;
[a,e] = lpc(x,p);
%a = a.*(e);
X =fft(x);
X = X(1:N/2+1)';
X = abs(X);
X = 10*log10(abs(X));

Z = fft(a,N);
Z = 1./Z(1:N/2+1);
Z = abs(Z);
Z = Z*(1/e);
%Z = Z*e;
%Z = Z*sqrt(e);
%Z = Z*sqrt(1/e);

Z = 10*log10(abs(Z));

figure;
plot(X);
hold on;
plot(Z,'r');
grid;
offset = 24;
figure;
plot(X+offset);
hold on;
plot(Z,'r');
grid;
```
```With some friend's help,I have acquired the exact multiplication

Although almost 90 percent of friends think the true multiplication
factor is sqrt(e), but the real one is
where,e refer to as the variance of prediction error ,the returned
value from lpc function.
N is the signal length.

Thank Rune Allnor.

But I am still puzzled with Why use energy sqrt(e*N) ,not power
(virance) sqrt(e), to be the true multiplication factor.

According to LPC theory,synthesis filter
H = G./[1-sum(ai.*Z.(-i))],

E(n) = s(n) - sp(n) = G*e(n);

here,E(n) refer to as lpc pediction error, and e(n) refer to as
excitation.
s(n) is the input speech,sp(n) is the estimated signal.

Assume the variance of e(n) to be 1.

sum( E(n)*E(n)) = G.^2*sum( e(n)*e(n)) = G.^2* N;

then G^2 = [sum( E(n)*E(n) ) ] ./ N.

It should be variance(power),not energy. Why?

Please tell the principle,not try to match the 2 spectrum curves
rouglyh without explanation.

Here is the matlab script which use " sqrt(e*N)" to illustrate it.

N = 25600;
[x,fs] = wavread('lpc.wav',N);    % any speech signal can be used

p=12;
[a,e] = lpc(x,p);

X =fft(x);
X = X(1:N/2+1)';
X = 10*log10(abs(X).^2);

Z = fft(a,N);
Z1 = 1./Z(1:N/2+1);

Z = Z1.*sqrt(e*N);  % to use sqrt(e*N),not sqrt(e),Why?
Z = 10*log10(abs(Z).^2);

figure;
plot(X);
hold on;
plot(Z,'r');
grid;

--- Z = Z1.*sqrt(e*N);  % to use sqrt(e*N),not sqrt(e),Why?

Cheers
HyeeWang
```
```On Feb 19, 2:02&#2013266080;pm, HyeeWang <hyeew...@gmail.com> wrote:
> With some friend's help,I have acquired the exact multiplication
>
> Although almost 90 percent of friends think the true multiplication
> factor is sqrt(e), but the real one is
> where,e refer to as the variance of prediction error ,the returned
> value from lpc function.
> N is the signal length.
>
> Thank Rune Allnor.
>
> But I am still puzzled with Why use energy sqrt(e*N) ,not power
> (virance) sqrt(e), to be the true multiplication factor.
>
> According to LPC theory,synthesis filter
> H = G./[1-sum(ai.*Z.(-i))],
>
> E(n) = s(n) - sp(n) = G*e(n);
>
> here,E(n) refer to as lpc pediction error, and e(n) refer to as
> excitation.
> s(n) is the input speech,sp(n) is the estimated signal.
>
> Assume the variance of e(n) to be 1.
>
> sum( E(n)*E(n)) = G.^2*sum( e(n)*e(n)) = G.^2* N;
>
> then G^2 = [sum( E(n)*E(n) ) ] ./ N.
>
> It should be variance(power),not energy. Why?
>
> Please tell the principle,not try to match the 2 spectrum curves
> rouglyh without explanation.
>
> Here is the matlab script which use " sqrt(e*N)" to illustrate it.
>
> N = 25600;
> [x,fs] = wavread('lpc.wav',N); &#2013266080; &#2013266080;% any speech signal can
be used
>
> p=12;
> [a,e] = lpc(x,p);
>
> X =fft(x);
> X = X(1:N/2+1)';
> X = 10*log10(abs(X).^2);
>
> Z = fft(a,N);
> Z1 = 1./Z(1:N/2+1);
>
> Z = Z1.*sqrt(e*N); &#2013266080;% to use sqrt(e*N),not sqrt(e),Why?
> Z = 10*log10(abs(Z).^2);
>
> figure;
> plot(X);
> hold on;
> plot(Z,'r');
> grid;
>
> --- Z = Z1.*sqrt(e*N); &#2013266080;% to use sqrt(e*N),not sqrt(e),Why?
>
> Any comments would be apprecited.
>
> Cheers
> HyeeWang

Modification for last post,it is sqrt(e*N),not sqrt(e)*N.
Sorry!
```