The downsampling factor (commonly denoted by M) is usually an integer or a rational fraction greater than unity. This factor multiplies the sampling time or, equivalently, divides the sampling rate. For example, if 16-bit compact disc audio (sampled at 44,100 Hz) is downsampled to 22,050 Hz, the audio is said to be downsampled by a factor of 2. The bit rate is also reduced in half, from 1,411,200 bit/s to 705,600 bit/s, assuming that each sample retains its bit depth of 16 bits.
Maintaining the sampling theorem criterion
Since downsampling reduces the sampling rate, it is usually a good idea to make sure the Nyquist–Shannon sampling theorem criterion is maintained relative to the new lower sample rate, to avoid aliasing in the resulting digital signal. To ensure that the sampling theorem is satisfied, or approximately so, a low-pass filter is used as an anti-aliasing filter to reduce the bandwidth of the signal before the signal is downsampled; the overall process (low-pass filter, then downsample) is sometimes called decimation.
If the original signal had been bandwidth limited, and then first sampled at a rate higher than the Nyquist rate, then the sampled signal may already have a bandwidth compliant with the requirements of the sampling theorem at the lower rate, so the downsampling can be done directly without any additional filtering. Downsampling only changes the sample rate, not the bandwidth, of the signal. The only reason to filter the bandwidth is to avoid the case where the new sample rate would become lower than the Nyquist rate and cause aliasing.
In some cases, the anti-aliasing filter can be a band-pass filter; the aliasing inherent in downsampling will then transpose a band of interest to baseband samples. A bandpass signal, i.e. a band-limited signal whose minimum frequency is different from zero, can be downsampled avoiding superposition of the spectra if certain conditions are satisfied; see undersampling.
Downsampling by integer factor
Downsampling a sequence by retaining only every Mth sample creates a new sequence If the original sequence contains significant normalized frequency components in the region (cycles/sample), the downsampler should be preceded by a low-pass filter with cutoff frequency .[note 1] In this application, such an anti-aliasing filter is referred to as a decimation filter, and the combined process of filtering (convolution) and downsampling is called decimation.
The process described above would generate an output sample for every input sample, and then M-1 of every M outputs would be discarded. Such is the process for an IIR filter that relies on feedback from output to input. With FIR filtering, it is an easy matter to compute only every Mth output. The calculation performed by a decimating FIR filter for the nth output sample is a dot product:
where the h[•] sequence is the impulse response, and K is its length. In a general purpose processor, after computing y[n], the easiest way to compute y[n+1] is to advance the starting index in the x[•] array by M, and recompute the dot product.
Impulse response coefficients taken at intervals of M form a subsequence, and there are M such subsequences (phases) multiplexed together. The dot product is the sum of the dot products of each subsequence with the corresponding samples of the x[•] sequence. Furthermore, because of decimation by M, the stream of x[•] samples involved in any one of the M dot products is never involved in the other dot products. Thus M low-order FIR filters are each filtering one of M multiplexed phases of the input stream, and the M outputs are being summed. This viewpoint offers a different implementation that might be advantageous in a multi-processor architecture. In other words, the input stream is demultiplexed and sent through a bank of M filters whose outputs are summed. When implemented that way, it is called a polyphase filter.
For completeness, we now mention that a possible implementation of each phase is to replace the coefficients of the other phases with zeros in a copy of the h[•] array, process the original x[•] sequence at the input rate, and decimate the output by a factor of M. The equivalence of this inefficient method and the implementation described above is known as the first Noble identity.
Downsampling by rational fraction
Let M/L denote the downsampling factor.
- Upsample by a factor of L
- Downsample by a factor of M
A proper upsampling design requires an interpolation filter after increasing the data rate and that a proper downsampling design requires a filter before eliminating some samples. These two low-pass filters can be combined into a single filter.
These two steps are generally not interchangeable. Downsampling results in a loss of data and, if performed first, could result in data loss if there is any data filtered out by the downsampler's low-pass filter. Since both interpolation and anti-aliasing filters are low-pass filters, the filter with the smallest bandwidth is more restrictive and can therefore be used in place of both filters. When the rational fraction M/L is greater than unity then L < M and the single low-pass filter should have cutoff at cycles/sample.
NOTE: Upsampling first is necessary in all cases where the rate is not an even multiple. E.g.: if a sample rate of 2x is changed to a rate of 1x by averaging every pair of samples this would be equivalent to a low pass filtering operation. But taking every other sample would be equivalent to up then down sampling in this special case where the multiple was 2 to 1, so there is no need to do an upsample first.
Discrete-time Fourier transform (DTFT)
Let X(f) be the Fourier transform of any function, x(t), whose samples at some interval, T, equal the x[n] sequence. Then the DTFT of the x[n] sequence is the Fourier series representation of a periodic summation of X(f):
When T has units of seconds, has units of hertz. Replacing T with MT in the formulas above gives the DTFT of the decimated sequence, x[nM]:
The periodic summation has been reduced in amplitude and periodicity by a factor of M. Aliasing occurs when adjacent copies of X(f) overlap. If an anti-aliasing filter is applied to the x[n] sequence, it should have a cutoff frequency hertz at sample-rate 1/T, or (equivalently) a cutoff at normalized frequency 1.0 cycles/sample.
Alternatively, the sample-rate can be presumed to be held constant, meaning that the interval between the retained samples is reduced from MT to T. The resulting Fourier series is:
The original periodicity is restored, but is M times wider than which can cause adjacent copies to overlap unless the x[n] sequence is pre-filtered as described above. Eq.2 and Eq.3 are identical, except for a frequency scale factor.
The z-transform of the x[n] sequence is defined by:
- where z is a complex variable.[note 2]
The z-transform of the decimated sequence is:
The periodicity of each "k" term is 2πM radians, and the terms are offset by multiples of 2π. So the periodicity of the summation is 2π (as required by the z-transform definition). The k=0 term is stretched across 2πM radians, which means that it exceeds the unit circle and folds back on itself M-1 times, or (equivalently) it overlaps and is overlapped by the other M-1 terms of the summation. But if its expanded bandwidth is still limited to the region the folding/overlapping does not cause aliasing. That can be assured by an anti-alias filter with a cutoff frequency < π/M at frequency 2π (radians/sample), or (equivalently) a cutoff at frequency 1.0 cycles/sample.
- Realizable low-pass filters have a "skirt", where the response diminishes from near unity to near zero. So in practice the cutoff frequency is placed far enough below the theoretical cutoff that the filter's skirt is contained below the theoretical cutoff.
- In a discussion involving multiple types of transforms, it is a common practice to distinguish them on the basis of their arguments, rather than the function name.
- Fourier transform is denoted by or
- Z transform is denoted by
- DTFT is denoted by or but sometimes or
- [Gilbert]; Nguyen, Truong (1996-10-01). Wavelets and Filter Banks (2 ed.). Wellesley,MA: Wellesley-Cambridge Press. pp. 100–101. ISBN 0961408871.
- Schniter, Phil (March 2006). "ECE-700 Multirate Notes". p. 2. Retrieved 2013-12-10.
- "DSP and Digital Filters (2013-3810)". 2013. p. 68. Retrieved 2013-12-10.
- Oppenheim, Alan V.; Ronald W. Schafer, John R. Buck (1999). Discrete-Time Signal Processing (2nd ed.). Prentice Hall. ISBN 0-13-754920-2.
- Proakis, John G. (2000). Digital Signal Processing: Principles, Algorithms and Applications (3rd ed.). India: Prentice-Hall. ISBN 8120311299.