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:
- Generate predictive filter coefficients
- Filter signal with these coefficients to obtain and error signal $r[n]$.
- Check if $r[n]$ is white.
- If it is, store the variance of $r[n]$ along with the coefficients and you are done.
- If not, increase order until (hopefully) $r[n]$ becomes white.
- With the encoding variance, produce a white signal.
- Pass that white signal through the inverse filter.
- 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;
noise = sqrt(variance)*randn(length(y),1); %compare noise to error signal plot(t,error,t,noise)
%synthesize signal yrecon = filter(1,a,noise); %actual signal, as produced by our residual yact = filter(1,a,error); plot(t,yrecon,t,yact); title('Signal vs synthesized signal')
%check autocorrelation sequence of each and plot [yacs, ylags] = xcorr(y,'coeff'); [yracs, yrlags] = xcorr(yrecon, 'coeff'); subplot(2,1,1) plot(yrlags,yracs), grid title('Autocorrelation sequence of reconstructed signal') subplot(2,1,2) plot(ylags, yacs), grid title('Autocorrelation sequence of signal'}