I have some data that is highly correlated and I wanted to see if I could try and encode it using linear predictive coding (LPC). Here is how I've been understanding the process:


  1. Generate predictive filter coefficients
  2. Filter signal with these coefficients to obtain and error signal $r[n]$.
  3. Check if $r[n]$ is white.
  4. If it is, store the variance of $r[n]$ along with the coefficients and you are done.
  5. If not, increase order until (hopefully) $r[n]$ becomes white.


  1. With the encoding variance, produce a white signal.
  2. Pass that white signal through the inverse filter.
  3. You produce a signal $s[n]$ that has the same autocorrelation sequence and power spectrum as your original.

I've completed all the encoding steps - computed my coefficients, checked if my residual signal was white (autocorrelation is a delta function) and then stored its variance. However, the trouble comes during the decoding process. I took the variance I encoded, produced white noise, and filtered it with the inverse filter. Not only was my signal nowhere near a representation of my old signal, but the two signals had very different autocorrelation sequences as well. I've posted my code and my outputs below. I mainly just want to know if I'm misunderstanding something about LPC or if I'm implementing it wildly incorrectly.

load('amp.mat') %this gets loaded as the variable y with timestamp t

order = 15;
[a,variance] = aryule(y,order);
error = filter(a,1,y);

%Now check to see if error is white

[acs, lags] = xcorr(error,'coeff');
plot(lags,acs), grid;

enter image description here

noise = sqrt(variance)*randn(length(y),1);

%compare noise to error signal

enter image description here

%synthesize signal
yrecon = filter(1,a,noise);
%actual signal, as produced by our residual
yact = filter(1,a,error);

title('Signal vs synthesized signal')

enter image description here

%check autocorrelation sequence of each and plot
[yacs, ylags] = xcorr(y,'coeff');
[yracs, yrlags] = xcorr(yrecon, 'coeff');
plot(yrlags,yracs), grid
title('Autocorrelation sequence of reconstructed signal')
plot(ylags, yacs), grid
title('Autocorrelation sequence of signal'}

enter image description here

  • 1
    $\begingroup$ wow it's exremely efficient to store only the variance of $r[n]$... ;-) consider a signal of length 1 G samples and you reduce it to a few prediction coefficients and a single variance ? something wrong ? $\endgroup$ – Fat32 Nov 25 '18 at 16:02
  • $\begingroup$ I agree that something seems wayyyy off haha. I mean I've tried increasing the number of prediction coefficients, but it neither makes the error 'more white' nor does it seem to make the auto correlation sequences more similar. I apologize, but I'm just really out of my depth here, I've looked all over for examples of implementing LPC for compression but I can't find any worked out examples so I've been trying to do it myself. I just figured that if I can get the residual to be white by removing all correlations in the signal, I've finished the encoding process. I'm guessing that's not true? $\endgroup$ – compscinoob Nov 25 '18 at 19:23
  • $\begingroup$ do you know what LPC is used for and how it does achieve its purpose ? $\endgroup$ – Fat32 Nov 25 '18 at 20:24
  • $\begingroup$ LPC is mianly used for speech because it's designed to fit the model of our vocal system. Our speech is modeled as a filter that is excited by either an impulse train or white noise. I do not know how it achieves its purpose. Although it's used mainly for speech, I don't see why it can't be used for any general signal that's correlated and can be reduced to some residual white noise. Maybe I'm misunderstanding everything, but I would really appreciate it if you could tell me how I could correct my already existing implementation and/or my understanding of LPC. $\endgroup$ – compscinoob Nov 27 '18 at 14:10
  • $\begingroup$ You are ok with the predictive part of the LPC. But it seems you have a problem with the coding part of it; that's where the compression actually takes place. You should consider the quantization stage carefully. I suggest you read Introduction to Data Compression by Khalid Sayood. For a full grasp of LPC and other data compression methods. $\endgroup$ – Fat32 Nov 27 '18 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.