# What is the need for prediction filter in PCM and DPCM?

The DPCM works by the difference between actual samples and predicted samples.

If we already have the actual samples, we can quantize it and encode it later.

• But why we use prediction filter?
• And by the definition "predicts the present samples with previous samples" how does the filter do that?

## 3 Answers

The DPCM works by the difference between actual samples and predicted samples.

If we already have the actual samples, we can quantize it and encode it later.

• But why we use prediction filter?

the idea is to transmit the D (or $e[n]$) and let the receiver add that to the previous PCM sample it has (or can predict from the previous PCM samples using the same predictor). and the reason was that, if the prediction was good, then $e[n]$ would be small and a smaller word width was needed.

• And by the definition "predicts the present samples with previous samples" how does the filter do that?

the idea is that a good prediction of $x[n]$ is a linear combination of $x[n-1]$, $x[n-2]$, $x[n-3]$, $x[n-4]$... $x[n-N]$. so some guys in the sixties just suggested that the prediction is:

$$\hat{x}[n] \triangleq a_1\, x[n-1] \ + \ a_2\, x[n-2] \ + \ a_3\, x[n-3] \ + ... + \ a_N\, x[n-N]$$

the prediction error is

$$e[n] \triangleq \hat{x}[n] - x[n]$$

and this $e[n]$ is what is transmitted and the next PCM sample can be constructed from the previous PCM samples and the error as

\begin{align} x[n] &= \hat{x}[n] \ - \ e[n] \\ &= a_1\, x[n-1] \ + \ a_2\, x[n-2] \ + \ a_3\, x[n-3] \ + ... + \ a_N\, x[n-N] \ - \ e[n] \end{align}

you can see that the prediction is a linear FIR filter and that the reconstruction has feedback and is a linear IIR filter (that happens to have all of the zeros at the origin, sometimes called an "all-pole filter" which is slightly imprecise).

then the idea is to, with knowledge of the statistical spectral characteristics of $x[n]$, namely its autocorrelation, find the values of $a_1$, $a_2$, $a_3$, ... such that the prediction is the best, that is such that $|e[n]|^2$ is minimized in a statistical manner. this is what linear predictive coding (LPC) is at the most fundamental. smaller $e[n]$ means that the word width needed for that signal is smaller and that the number of bits you need to send $e[n]$ over a transmission channel is less. and, it means you can add Shannon and Huffman to the mix and send even fewer bits over the channel. that is one way to do lossless coding.

But why we use prediction filter?

The issue is that we want to send as accurate a sampled version of the signal as possible now. And, depending on the signal, we may be able to predict it pretty well.

That way, the predicted signal, $\hat{x}(t)$ will be "close" to the real signal $x(t)$, except for some prediction error $e(t)$. Provided the predictor accurately reflects the signal model that generated $x(t)$, the prediction error should be white.

The black arrow in the diagram indicates the sampled signal being sent somewhere else where we don't have access to $x(t)$.

And by the definition "predicts the present samples with previous samples" how does the filter do that?

The filter does that by being as accurate as possible a match to the unknowable filter that generated the signal in the first place. For speech, this is generally an AR (LPC) filter. Other signal types have different signal models.

But why we use prediction filter?

To reduce the error we would have by encoding the actual sample directly.

How does the filter do that?

By combining past values in a clever way. If you are disturbed by filter, you can call it (linear) extrapolation, just a different way of looking at it.

DPCM may encode signals more efficiently, using the past known values. For instance, dealing with a sampled signal (would work in a similar manner for analog signals), the idea is to encode:

• on a smaller size (less bits), with the same precision as the original signal (as a form of lossless compression),
• on a smaller size (less bits), with better precision than if one had quantized the original signal to that smaller size, sample per sample (as a form of lossy compression).

The hypothesis is that past values can predict, more or less faithfully, the actual value. This tends to work poorly for random data, but generally works fine, on average, for signals bearing information, that is, having some regularity.

For instance, if the signal looks (a least on a short time period) like a line, you can predict ${x}[0]$ from previous samples ${x} [-1]$ and ${x} [-2]$ with

$$\hat{x}[0] = 2{x}[-1]- {x}[-2]\,.$$

Do not forget that the older sampled (could) have been previously quantified: we write them ${x}_Q[-1]$ and ${x}_Q[-2]$, so actually:

$$\hat{x}[0] = 2{x}_Q[-1]- {x}_Q[-2]\,.$$

Even if your signal is not exactly linear, you can expect that, quite often, the prediction error $e[0]={x}[0]-\hat{x}[0]$ will be smaller than ${x}[0]$. Hence, if you quantize ${x}[0]-\hat{x}[0]$ instead of ${x}[0]$, with the quantization function $\mathcal{Q}$, you can reconstruct the final ${x}_Q[0]$ as:

$$\mathcal{Q}(e[0])+2{x}_Q[-1]- {x}_Q[-2]\,,$$ hopefully closer to $x[0]$ than with a direct quantization $\mathcal{Q}(x[0])$.

Of course, you can use more samples from the past, prediction functions different from a linear combination, pre-processing on the samples, adaptive modification of the coefficients (ADPCM).

From An illustration of DPCM's advantages over PCM, you can see the interest, looking at histograms. Suppose you want to requantize an image, its histogram is:

and its DPCM histogram is:

As the second histogram contains all the necessary information to reconstruct the image, and is better concentrated around $0$ values, with very few high values, apply $\mathcal{Q}$ on it results in smaller errors than applying $\mathcal{Q}$ on the first histogram.

• love your histograms, L. now can you imagine applying Huffman coding on the DPCM and reducing the bits even further? Aug 27, 2016 at 23:15
• @robert bristow-johnson This is exactly what is done in Shorten for waveforms signals ee.columbia.edu/~dpwe/papers/Robin94-shorten.pdf. You should modify it though for high-dynamic range signals. Does that answer? Aug 27, 2016 at 23:21
• @robert bristow-johnson But you know that, this was already in your answer... Aug 27, 2016 at 23:23