### Downsample

In signal processing, downsampling (or "subsampling") is the process of reducing the sampling rate of a signal. This is usually done to reduce the data rate or the size of the data.

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 process

Consider a discrete signal $f\left(k\right)$ on a radian frequency digital frequency range.

### Downsampling by integer factor

Let M denote the downsampling factor.

1. Filter the signal to ensure that the sampling theorem is satisfied. This filter should, theoretically, be the sinc filter with frequency cutoff at $\frac\left\{\pi\right\}\left\{M\right\}$. Let the filtered signal be denoted $g\left(k\right)$.
2. Reduce the data by picking out every $M^\left\{th\right\}$ sample: $h\left(k\right) = g\left(Mk\right)$. Data rate reduction occurs in this step.

The first step calls for the use of a perfect low-pass filter, which is not implementable for real-time signals. When choosing a realizable low-pass filter this will have to be considered along with the aliasing effects it will have. 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.

### Downsampling by rational fraction

Let M/L denote the downsampling factor.

1. Upsample by a factor of L
2. 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 reversible. 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 $\pi/M$.

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.

## Effect on Z transform of signal

The simplest downsampling or decimation process is to just keep every Nth sample from the original. This process aliases the high frequencies, unless an anti-aliasing filter is used ahead of it to remove frequencies above half the new sample rate. The aliasing can be seen by examining the Z transform.

### Decimation by factor of 2

From the definition of the z transform, $H\left(z\right)$ of the signal $h\left[k\right]=g\left[2k\right]$ we have

$H\left(z\right) = \sum_\left\{k=0\right\}^\left\{\infty\right\} h\left[k\right] z^\left\{-k\right\} = \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[2k\right] z^\left\{-k\right\} = \sum_\left\{k=0,2,4,6,...\right\} g\left[k\right] z^\left\{-k/2\right\} = \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] z^\left\{-k/2\right\} q\left[k\right]$

Where $q\left[k\right] = 1, 0, 1, 0, 1, ...$

It can be shown that $q\left[k\right]=\tfrac\left\{1\right\}\left\{2\right\}\left(\left(-1\right)^\left\{-k\right\} + 1\right)$ satisfies this condition. By substituting, we obtain

$H\left(z\right) = \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] z^\left\{-k/2\right\} \tfrac\left\{1\right\}\left\{2\right\}\left(\left(-1\right)^\left\{-k\right\} + 1\right)$ $= \tfrac\left\{1\right\}\left\{2\right\}\left(\sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] \left(-1\right)^\left\{-k\right\}\left(z^\left\{1/2\right\}\right)^\left\{-k\right\} + \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] \left(\left(z\right)^\left\{1/2\right\}\right)^\left\{-k\right\}\right)$ $= \tfrac\left\{1\right\}\left\{2\right\}\left(\sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] \left(-z^\left\{1/2\right\}\right)^\left\{-k\right\} + \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] \left(z^\left\{1/2\right\}\right)^\left\{-k\right\}\right) = \tfrac\left\{1\right\}\left\{2\right\}\left(G\left(-z^\left\{1/2\right\}\right) + G\left(z^\left\{1/2\right\}\right)\right)$

Where $G\left(z\right)$ is the z transform of the original, unmodified signal $g\left[k\right]$

The aliasing comes from the fact that $G\left(z^\left\{1/2\right\}\right)$ is multi-valued, such that several frequencies of the original transform contribute to any frequency in the new transform.

### Decimation by factor of 3

This amounts to keeping every third sample, so we have $h\left[k\right]=g\left[3k\right]$.

We can use the same technique as used for decimation by factor 2, resulting in

$H\left(z\right) = \sum_\left\{k=0\right\}^\left\{\infty\right\} g\left[k\right] z^\left\{-k/3\right\} q\left[k\right]$

and choosing a $q\left[k\right] = 1, 0, 0, 1, 0, 0, 1, 0, 0, \dots$

The formula that satisfies this requirement is $q\left[k\right] = \tfrac\left\{2\right\}\left\{3\right\}\left(\cos\left(\tfrac\left\{2\pi k\right\}\left\{3\right\}\right) + \tfrac\left\{1\right\}\left\{2\right\}\right) = \tfrac\left\{1\right\}\left\{3\right\}\left(\exp\left(\tfrac\left\{i 2\pi k\right\}\left\{3\right\}\right) + \exp\left(\tfrac\left\{-i 2\pi k\right\}\left\{3\right\}\right) + 1\right)$

By a similar process of reasoning, as used in the decimation by 1 case, we obtain

$H\left(z\right) = \tfrac\left\{1\right\}\left\{3\right\}\left(G\left(\left(ze^\left\{-i2\pi\right\}\right)^\left\{1/3\right\}\right) + G\left(\left(ze^\left\{i2\pi\right\}\right)^\left\{1/3\right\}\right) + G\left(z^\left\{1/3\right\}\right)\right)$

### Decimation by other factors

The following formulae are useful to derive the Z transform relation for other factors x:

If x > 3 is odd, we have $q\left[k\right]=\tfrac\left\{2\right\}\left\{x\right\}\left(\tfrac\left\{1\right\}\left\{2\right\}+\sum_\left\{n=1\right\}^\left\{\tfrac\left\{1\right\}\left\{2\right\}\left(x-1\right)\right\} \cos\left(\tfrac\left\{2\pi nk\right\}\left\{x\right\}\right)\right) = \left \\left\{ \begin\left\{matrix\right\} 1 & \mbox\left\{if \right\} \frac\left\{k\right\}\left\{x\right\} \mbox\left\{ is an integer\right\} \\ 0 & \mbox\left\{otherwise\right\} \end\left\{matrix\right\} \right.$

If x = 4, we have $q\left[k\right]=\tfrac\left\{1\right\}\left\{4\right\}\left(1 + \left(-1\right)^k + 2\cos\left(\tfrac\left\{2\pi k\right\}\left\{4\right\}\right)\right) = \left \\left\{ \begin\left\{matrix\right\} 1 & \mbox\left\{if \right\} \frac\left\{k\right\}\left\{x\right\} \mbox\left\{ is an integer\right\} \\ 0 & \mbox\left\{otherwise\right\} \end\left\{matrix\right\} \right.$

If x = 6, we have $q\left[k\right]=\tfrac\left\{2\right\}\left\{x\right\}\left(\tfrac\left\{1\right\}\left\{2\right\}+\cos\left(\tfrac\left\{4\pi k\right\}\left\{x\right\}\right)\right)\left(1 + \left(-1\right)^k\right) = \left \\left\{ \begin\left\{matrix\right\} 1 & \mbox\left\{if \right\} \frac\left\{k\right\}\left\{x\right\} \mbox\left\{ is an integer\right\} \\ 0 & \mbox\left\{otherwise\right\} \end\left\{matrix\right\} \right.$