# 18.17.2 Algorithm (Decimate)

Two filters can be used to perform the decimation, including FIR filter and moving average filter.

## FIR Filter

FIR filter used in this X-Function is a finite impulse response filter based on regular window. The filter order is specified by the Order variable.

## Moving Average Filter

When the Moving Average filter is applied, Origin performs the following steps:

1. Generate a new dataset $g(x)$ with the same size of the input range. Each datum in the new dataset is the average of the data points within the moving window. The size of the moving window is determined by the Resample Factor $I$ specified in the dialog. Let {$f(x_i)|i=1, 2, ..., N$} be the Y value of the input data points and {$g(x_i)|i=1, 2, ..., N$} denote the Y value of the new dataset, where $N$ is the size of the dataset. Each $g(x_i)$ is computed by the following formula:
$g(x_i)= \begin{cases} \frac{\textstyle \sum_{k=0}^{I} f(x_{N-(i-1)-k})}{I+1}, & iN-I \end{cases}$
2. Repeat the calculating process in step 1. This time using the new created dataset $g(x)$ as the input range to create a new dataset $h(x)$.
3. Use the new created dataset $h(x)$ as the input range to perform decimation with no filter applied.