Random Signals and LTI-Systems
🏃🏻 Getting Started Guide
This document can be executed directly on the Bohrium Notebook. To begin, click the Connect button located at the top of the interface, then select the digital-signal-processing:Digital-Signal-Processing-Lecture Image and choose your desired machine configuration to proceed.
📖 Source
This Notebook is from a famous Signal Processing Lecture. The notebooks constitute the lecture notes to the masters course Digital Signal Processing read by Sascha Spors, Institute of Communications Engineering, Universität Rostock.
This jupyter notebook is part of a collection of notebooks on various topics of Digital Signal Processing. Please direct questions and suggestions to Sascha.Spors@uni-rostock.de.
Linear Prediction
In general, predictive modeling aims at predicting outcomes using (statistical) models of the underlying processes. When applied to discrete-time signals, it refers to predicting future values from past ones. Different signal models are used for this purpose. Forward linear prediction aims at predicting the actual value of a discrete random signal by a linear combination of its past values. It is frequently applied in lossless and lossy coding of signals. For instance, linear predictive coding (LPC) is a major building block of many speech coding and speech synthesis techniques.
Theory
It is assumed that is a real-valued discrete-time random signal. The prediction of the current sample is computed from a weighted superposition of the past samples
where denotes the order of the predictor and the weights of the past samples at time-instant . The weights might differ for different time-instants. This constitutes a moving average (MA) model or a linear filter with finite impulse response (FIR). Therefore the weights can be interpreted as the filter coefficients of a time-variant non-recursive FIR filter.
It is beneficial to express above sum as an inner product of vectors. Combining the filter coefficients and the samples of the signal into the vectors (i.e. column vectors)
yields
for the above sum equation.
The aim of linear prediction is to determine the filter coefficients such that the predicted signal matches the signal as close as possible. In order to quantify the deviation between the signal and its predicted value at time-instance , the error signal
is introduced. The error equals zero, if the signal is perfectly predicted. In general, this cannot be achieved by a finite predictor order . The problem of determining suitable filter coefficients could be approached by directly minimizing the (average) error. However, this constitutes a non-convex optimization problem. Instead, the quadratic average of the error is typically used. This measure is known as mean squared error (MSE). It is defined as
Above equation is referred to as cost function of the optimization problem. We aim at minimizing the cost function, hence minimizing the MSE between the signal and its prediction . The solution of this convex optimization problem is referred to as minimum mean squared error (MMSE) solution. Minimizing the cost function is achieved by calculating its gradient with respect to the filter coefficients [Haykin] using results from matrix calculus
where
denote the auto-correlation matrix and cross-correlation vector, respectively. The elements of the auto-correlation matrix can be interpreted by expanding the outer product and using the definition of the auto-correlation function (ACF)
The matrix is composed from the values of the ACF for all combinations of time indexes. It is symmetric with respect to its main diagonal. The elements on the main diagonal constitute the quadratic means for the respective time indexes. The elements of the cross-correlation vector are given as
As the MMSE solution constitutes a convex optimization problem, the minimum of the cost function is found by setting its gradient to zero, . Rearranging terms this results in the Wiener-Hopf equation
If has full rank (which should hold due to the random signal assumption), the optimum filter coefficients in the MMSE sense are given as
i.e. solving the Wiener-Hopf equation by direct matrix inverse.
Note that various alternative solutions to the Wiener-Hopf equation have been developed which avoid the direct inversion of the auto-correlation matrix. For instance the least-mean squares (LMS) filter which uses steepest gradient descent to solve for . This is also known as Widrow-Hopf solution.
Example - Linear Prediction of a Speech Signal
In the following example, the principle of forward linear prediction is applied to the recording of a speech signal. The recording contains the stationary part of the vocal 'o'. This constitutes a random signal which can be considered reasonably well as wide-sense stationary (WSS). It follows from the properties of the ACF that
where denote the time-invariant weights of the predictor. As we only have access to one recorded instance of the vocal, we inherently assume wide-sense ergodicity. The expectations are computed by averaging with respect to time.
Computation of prediction filter
First the signal is loaded, conditioned and truncated
The auto-correlation matrix and the cross-correlation vector are estimated by averaging with respect to time. For instance
where denotes the total number of samples of .
Let's inspect the estimated auto-correlation matrix by plotting its values within a surface plot
<Figure size 300x300 with 0 Axes>
As expected, the elements on the main diagonal have the largest values. The values decay with an increasing distance of the minor diagonals. Hence, the statistical dependencies between samples at two different time instants of the signal decrease with an increasing distance between the samples. These statistical dependencies are exploited for the prediction of the current signal value from past ones.
Now the filter coefficients are computed and plotted.
Forward prediction
The value of the signal at time-instant is predicted from its past values by evaluating the equation given above. This essentially constitutes a linear convolution with the forward prediction filter
In order to evaluate the predictor, the predicted signal is computed for all time instants and plotted in comparison with the signal .
As the difference between the actual signal and its prediction is quite low, the error is computed and plotted for inspection.
The amplitude of the error is much lower than the amplitude of the signal. This shows that the signal can be well predicted by the computed predictor. In order to quantify this, the variance of the signal and the error is computed as measure of their average power. Note, both signals are assumed to be zero-mean.
Variance of signal 0.060221 Variance of error 0.000011
Prediction from residual error
The error signal may be rewritten as
where
denotes the prediction-error filter. Taking the -transform of the error signal yields
where for instance . From this result it can be concluded that the signal can be computed from the error signal by inverse filtering with the prediction-error filter
The inverse of the prediction-error filter constitutes an pole-only (recursive) filter as the prediction filter is a zero-only (non-recursive) filter. In the following, the signal is computed from the error signal and plotted.
Application - Speech synthesis using an artificial glottal signal
Linear prediction is used as linear predictive coding (LPC) in the coding and synthesis of speech signals. The latter application is briefly presented in the sequel. It bases on the source-filter model of human speech production. Here speech production is modeled as a sound source filtered by a linear acoustic filter. In the case of vocals, this sound source are the vocal cords which generate the periodic glottal signal. The vocal tract may be interpreted as an acoustic filter. Vocals are articulated by changing the air flow through the vocal cords, their state as well as the configuration of the vocal tract. Due to its acoustical properties, the vocal tract can be represented as a pole-only filter.
The basic idea of LPC-based speech synthesis is, that the inverse of the prediction-error filter is an pole-only filter. When interpreting the error signal as glottal signal in the source-filter model, the inverse of the prediction-error filter can be used to generate the speech signal . A synthetic vocal may be generated by using a synthetic glottal signal. A simple model for the glottal signal is a mean-free periodic rectangular signal with a duty cycle of 1:10. The signal is generated and plotted for illustration.
The spectral contents of the error signal and the synthetic glottal signal are compared by estimating their power spectral densities (PSDs) using the Welch technique.
The spectra of both signals constitute line-like spectra due to their periodicity. However, the levels of the spectral lines differ. This becomes most prominent around 600 Hertz. The synthetic glottal signal is now filtered with the inverse prediction-error filter in order to generate the synthetic speech signal.
Visual comparison with the recorded speech signal shown above yields that the coarse structure of both is quite similar. The differences are a consequence of the simple glottal signal used. Both signals may also be compared aurally by listening to them.
Copyright
This notebook is provided as Open Educational Resource. Feel free to use the notebook for your own purposes. The text is licensed under Creative Commons Attribution 4.0, the code of the IPython examples under the MIT license. Please attribute the work as follows: Sascha Spors, Digital Signal Processing - Lecture notes featuring computational examples.