## Topic: LPC spectra estimate (Read 13447 times)previous topic - next topic

0 Members and 1 Guest are viewing this topic.
• hyeewang
LPC spectra estimate
##### 05 February, 2009, 09:26:15 PM
LPC spectra should correspond with the envelope of DFT spectra.

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;

• SebastianG
• Developer
LPC spectra estimate
##### Reply #1 – 06 February, 2009, 06:10:10 PM
LPC spectra should correspond with the envelope of DFT spectra.
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?

What you call "LPC spectra" (by which you probably mean the LPC synthesis filter response) is independent of the input signal's level. If I remember correctly Matlab's LPC function can return more than the set of filter coefficients -- one of those return values gives you a hint about the scaling of the input.

Cheers!
SG

• hyeewang
LPC spectra estimate
##### Reply #2 – 06 February, 2009, 09:26:48 PM
LPC spectra should correspond with the envelope of DFT spectra.
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?

What you call "LPC spectra" (by which you probably mean the LPC synthesis filter response) is independent of the input signal's level. If I remember correctly Matlab's LPC function can return more than the set of filter coefficients -- one of those return values gives you a hint about the scaling of the input.

Cheers!
SG

Thank you.

Great job.
It must be here that lpc coefficients were scaled. I would confirm it soon.

• hyeewang
LPC spectra estimate
##### Reply #3 – 07 February, 2009, 09:51:58 AM
LPC spectra should correspond with the envelope of DFT spectra.
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?

What you call "LPC spectra" (by which you probably mean the LPC synthesis filter response) is independent of the input signal's level. If I remember correctly Matlab's LPC function can return more than the set of filter coefficients -- one of those return values gives you a hint about the scaling of the input.

Cheers!
SG

Thank you.

Great job.
It must be here that lpc coefficients were scaled. I would confirm it soon.

LPC function in matlab return LPC coefficients and prediction error variance sigma^2. And LPC  coefficients lost important signal energy

information.

But I still do not get the exact scale factor from returned value of lpc function.

Cheers

• SebastianG
• Developer
LPC spectra estimate
##### Reply #4 – 07 February, 2009, 10:54:44 AM

What you call "LPC spectra" (by which you probably mean the LPC synthesis filter response) is independent of the input signal's level. If I remember correctly Matlab's LPC function can return more than the set of filter coefficients -- one of those return values gives you a hint about the scaling of the input.

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

Bingo!

Guess what happens to this sigma^2 if you scale your input by factor two...

Cheers!
SG

• hyeewang
LPC spectra estimate
##### Reply #5 – 07 February, 2009, 08:58:13 PM

What you call "LPC spectra" (by which you probably mean the LPC synthesis filter response) is independent of the input signal's level. If I remember correctly Matlab's LPC function can return more than the set of filter coefficients -- one of those return values gives you a hint about the scaling of the input.

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

Bingo!

Guess what happens to this sigma^2 if you scale your input by factor two...

Cheers!
SG

Thank you.

It cause sigma^2 to  rise 4 times by scaling the input by factor two preceding lpc computation,.

but I still can not get the corresponding input signal power from prediction error variance sigma^2.

N = 25600;
[x,fs] = wavread('origsign.wav',N); % any speech signal can be used
y = 2*x;
p=20;
[a,ae] = lpc(x,p);
[b,be] = lpc(y,p);
be/ae

• SebastianG
• Developer
LPC spectra estimate
##### Reply #6 – 10 February, 2009, 03:44:01 AM
but I still can not get the corresponding input signal power from prediction error variance sigma^2.

If you still havn't figured out the details try

Z = fft(a,N);
Z = sqrt(e*N) ./ Z(1:N/2+1);  % <--- changed
Z = 10*log10(abs(Z).^2);

instead -- where 'e' is this sigma^2.

Cheers!
SG

• hyeewang
LPC spectra estimate
##### Reply #7 – 10 February, 2009, 10:17:55 PM
but I still can not get the corresponding input signal power from prediction error variance sigma^2.

If you still havn't figured out the details try

Z = fft(a,N);
Z = sqrt(e*N) ./ Z(1:N/2+1);  % <--- changed
Z = 10*log10(abs(Z).^2);

instead -- where 'e' is this sigma^2.

Cheers!
SG

Thank you.
I follow u and it work well.

But I did not get the principle,. why the multiplication factor is energy,not variance?

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?

• SebastianG
• Developer
LPC spectra estimate
##### Reply #8 – 11 February, 2009, 04:30:23 AM

Z = fft(a,N);
Z = sqrt(e*N) ./ Z(1:N/2+1);  % <--- changed
Z = 10*log10(abs(Z).^2);

instead -- where 'e' is this sigma^2.

I follow u and it work well.
But I did not get the principle

'a' and 'e' don't depend on the length of your signal (assuming its characteristics don't change over time). But you wanted both curves to match which is why I included 'N' in the scaling.

Also, are you confusing power with energy?

Cheers!
SG

• hyeewang
LPC spectra estimate
##### Reply #9 – 11 February, 2009, 08:25:21 AM

Z = fft(a,N);
Z = sqrt(e*N) ./ Z(1:N/2+1);  % <--- changed
Z = 10*log10(abs(Z).^2);

instead -- where 'e' is this sigma^2.

I follow u and it work well.
But I did not get the principle

'a' and 'e' don't depend on the length of your signal (assuming its characteristics don't change over time). But you wanted both curves to match which is why I included 'N' in the scaling.

Also, are you confusing power with energy?

Cheers!
SG

Thank you.

Hehe,I used the term power and energy by mistake. shame.

Indeed, Both a and e  do not depend on the length of signal.

But You use e*N,and e*N is the speech signal's energy.

And You still did not explain why you use N to multiply the varince e.

Just use the cause of curves matching reason is weak.

• SebastianG
• Developer
LPC spectra estimate
##### Reply #10 – 11 February, 2009, 11:05:22 AM
Indeed, Both a and e  do not depend on the length of signal.
But You use e*N,and e*N is the speech signal's energy.

Not exactly. It's the energy of the prediction residual.

And You still did not explain why you use N to multiply the varince e.
Just use the cause of curves matching reason is weak.

How about telling us why this isn't obvious to you?
What else do you expect?

You know, I really don't like writing big articles about this just so you can understand the topic. I value my sparetime. It's not my job to teach you in my sparetime. I'm just giving hints & pointers that are intended to make you think for yourself.

• hyeewang
LPC spectra estimate
##### Reply #11 – 11 February, 2009, 08:45:55 PM
Indeed, Both a and e  do not depend on the length of signal.
But You use e*N,and e*N is the speech signal's energy.

Not exactly. It's the energy of the prediction residual.

And You still did not explain why you use N to multiply the varince e.
Just use the cause of curves matching reason is weak.

How about telling us why this isn't obvious to you?
What else do you expect?

You know, I really don't like writing big articles about this just so you can understand the topic. I value my sparetime. It's not my job to teach you in my sparetime. I'm just giving hints & pointers that are intended to make you think for yourself.

Sorry for my remark about e, it is the variance of prediction error ,not that of the original speech signal.

Also Sorry for my annoying and continuous inquiring.

Actually,a few days ago,someone have told me about the true multiplication factor,which is N*e,not e. And explian it to use "LPC spectrum is, actually, amplitude characteristics of  LPC impulse response ...".

But I still do not get it fully.

Thus, why use N*e,not use e, is my focuse on, also it is the essence of this topic.

Sorry to disturb you.

I appreciate your help,but I also know it is not your job and responsibility.

- Reward the water of sea just for the tiny dripping.

-- A Chinese old proverb.

Thank you anyway.

• SebastianG
• Developer
LPC spectra estimate
##### Reply #12 – 12 February, 2009, 07:41:15 AM
But I still do not get it fully.

'a' is independent from your signal's level and length. 'e' corresponds to the residual's power. This means that if you take white noise with variance 1, multiply it with sqrt(e) and filter it with the LPC synthesis filter you'll get a signal with roughly the same power spectral density.

But you are actually comparing a single impulse response with a whole signal of length N. That's why you need the 'N' in "e*N" for the power scaling to make both curves match.

• hyeewang
LPC spectra estimate
##### Reply #13 – 18 February, 2009, 04:17:20 AM
But I still do not get it fully.

'a' is independent from your signal's level and length. 'e' corresponds to the residual's power. This means that if you take white noise with variance 1, multiply it with sqrt(e) and filter it with the LPC synthesis filter you'll get a signal with roughly the same power spectral density.

But you are actually comparing a single impulse response with a whole signal of length N. That's why you need the 'N' in "e*N" for the power scaling to make both curves match.

But you are actually comparing a single impulse response with a whole signal of length N. That's why you need the 'N' in "e*N" for the power scaling to make both curves match.

Thank you.

I am sorry that I think it is not logical.

You always try to roughly match the two curves by scaling the data,instead of telling the principle.

Just forget the curve of DFT spectrum,because the lpc spectrum exsit independent of DFT spectrum.

Even no the concept of DFT spectrum exist ,lpc spectrun should behave as it is.

Thank you anyway.

• SebastianG
• Developer
LPC spectra estimate
##### Reply #14 – 18 February, 2009, 04:44:48 PM
You always try to roughly match the two curves by scaling the data,instead of telling the principle.
Just forget the curve of DFT spectrum,because the lpc spectrum exsit independent of DFT spectrum.

Here's an extreme example that should make you think about what you're doing:

Compare the average power of
s1 = randn(1,1000); % white noise with variance 1
s2 = [1 zeros(1,999)]; % single pulse

Of course the average power levels don't match. But that's what you're doing -- essentially -- because 'a' would be a unit impulse in this case. You're comparing a single impulse response (inverse_of(a).*sqrt(e)) to a longer signal.

That's your explanation. That's the principle. This is not a rough match.

Perhaps you have a problem with what FFT does. There's a sqrt(N) scaling involved.

Try
> freqz(sqrt(e),a); % for plotting "LPC spectra"
and "pwelch" with sampling_rate=2 for plotting the estimated PSD for your signal -- or compute average power via abs(FFT(signal,N)).^2./N (note the divice by N)

• simoala007
LPC spectra estimate
##### Reply #15 – 18 February, 2012, 05:33:37 PM
Hello i have got a question regarding LPC theory:

e=signal_esti - signal
and then we find that Signal(Z)=e/H(Z) with H(Z)=(1+ ai(z(i)+....apz(p))

The problem is that we plot the entry signal, and then we compare it to signal_estimated.

so when we say:

> [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); =A0% to use sqrt(e*N),not sqrt(e),Why?
> Z = 10*log10(abs(Z).^2);

when we plot Z, we plot the original signal, and not the estimated signal !!!!!!!

Please i am stucked here i can't understand it well.
i want to plot the estimated signal in function of error, and now from theory we are ploting the original signal.
iS THERE SOMETHING WRONG WITH MY COMPREHENSION,
THANKS A LOT

• xiedanhui
LPC spectra estimate
##### Reply #16 – 07 March, 2012, 04:08:22 AM
Hello i have got a question regarding LPC theory:

e=signal_esti - signal
and then we find that Signal(Z)=e/H(Z) with H(Z)=(1+ ai(z(i)+....apz(p))

The problem is that we plot the entry signal, and then we compare it to signal_estimated.

so when we say:

> [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); =A0% to use sqrt(e*N),not sqrt(e),Why?
> Z = 10*log10(abs(Z).^2);

when we plot Z, we plot the original signal, and not the estimated signal !!!!!!!

Please i am stucked here i can't understand it well.
i want to plot the estimated signal in function of error, and now from theory we are ploting the original signal.
iS THERE SOMETHING WRONG WITH MY COMPREHENSION,
THANKS A LOT

(perhaps with many odd expressions and grammatical errors due to my poor English)

Once we get the lpc of the predication filter H(z) , we can say:
1. d[n] pass the filter H(z), results in x[n].% original signal.
2. delta[n] pass the filter H(z), results in h[n]. % impulse response.
where d[n] is the predicted error.

the lpc function in Matlab returns the lpc coefficients a and the prediction error variance g,
[a,g] = lpc(x,p). thus.
E{|d[n]|^2}=g.

actually, the ensemble average is difficult to calculate, and usually replaced it by the time average.
g={sum_{n=0}^{N-1}|d[n]|^2}/N.
N is the length of the original signal, not the length of latter FFT.

then the energy of the original signal x[n] equals gN  times the energy of the impulse response h[n].

therefore, when we compare the power density of the impulse response h[n] to that of the original signal x[n] (usually use FFT analysis method, e.g. M points FFT), we should multiply the impulse response h[n] by a factor (i.e. gN for power density, while sqrt(gN) for amplitude density).

the estimated signal can be calculated by the following:
est_x = filter([0 -a(2:end)],1,x);%estimated signal
where x is the original signal.