
Contents |
Smoothing
Perform smoothing to irregular and noisy data.
This feature is updated in 8.0 SR3. For more details, please refer to Release Notes.
1. smooth iy:=Col(2);
2. smooth iy:=Col(2) method:=aav npts:=51;
3. smooth iy:=Col(2) boundary:=periodic;
4. smooth iy:=Col(2) polyorder:=3;
5. smooth iy:=Col(2) method:=pf percent:=70;
| Display Name | Variable Name | I/O and Type | Default Value | Description |
|---|---|---|---|---|
| Input | iy |
Input XYRange | |
Specifies the input XY data range to be smoothed |
| Method | method |
Input int | |
Specifies the smoothing method to be used. The default is Savitzky-Golay. Option list
|
| Weighted Average | weight |
Input int | |
This parameter is available only when Method is Adjacent-Averaging. When this parameter is set to 1 (checked), weighted averaging will be used. |
| Points of Window | npts |
Input int | |
If FFT Filter is not selected for Method, this parameter specifies the number of points in the moving window. Otherwise, you can use this parameter to control the cutoff frequency for the FFT filter. The greater this value, the greater the degree of smoothing. A value of zero for this parameter will leave the data unsmoothed. See the Algorithm part for the computation of cutoff frequency. |
| Boundary Condition | boundary |
Input int | |
Specifies the boundary condition. It is not available when FFT Filter is selected for Method. Option list
|
| Polynomial Order | polyorder |
Input int | |
This parameter applies only to the Savitzky-Golay smoothing option. It specifies the polynomial order. |
| Percentile | percent |
Input double | |
This parameter determines the percentile to be used in percentile filtering. The default is 50%, which corresponds to replacing the signal point with median value of the data points in the data window. |
| Cutoff Frequency | cutoff |
Input double | |
This parameter is visible in GUI when FFT Filter is selected for Method. It is a read-only variable showing the cutoff frequency of the low-pass filter calculated from Points of Window. Please do not use it in script. |
| Pad to Power of 2 Points | pad |
Input int | |
This parameter is available only when FFT Filter is selected for Method. It is available only from script. It specifies whether to pad the number of data points to power of 2. When this is set to 1, the result will match the result calculated with Origin prior to the Version 8. See more details in the Algorithm part. |
| Filter Type | filter |
Input int | |
This parameter is available only when FFT Filter is selected for Method. It is available only from script. It specifies the filter type. When old is selected, the result will match the result calculated with Origin prior to the Version 8. Option list:
|
| Baseline to Subtract | baseline |
Input int | |
This parameter is available only when FFT Filter is selected for Method. It is available only from script. It specifies whether to subtract a baseline before fft filtering is used. Option list:
|
| Output | oy |
Output XYRange | |
Specifies the destination of smoothed signal. See the syntax here. |
1. To perform Savitzky-Golay filtering using default settings, to XY data in columns 1, 2 of the active worksheet, use the script command:
2. To perform default smoothing to active data plot in graph, use the script command:
3. To change the method of smoothing, either open the smoothing dialog and select a method from the drop down menu by typing:
Or specify which method of smoothing to use from the script line by typing, for example,
m:=1 corresponds to the (default) Savitzky-Golay method, m:=0 executes the Adjacent-Averaging method, and m:=2 corresponds to the percentile filter method.
4. To perform smoothing to column 1, 2 data using a pre-saved smoothing theme file, save your preferences in the smooth dialog, and then execute it by typing (for example, but using your own saved-theme title) the script command:
For more examples, please refer to XF Script Dialog (press F11).
When the smoothing method is adjacent-averaging, Savitzky-Golay or percentile filter, each smoothed data point is computed from data points within a moving window. Let {fi | i = 1,2,...,N} be the input data points and let {gi | i = 1,2,...,N} denote the output data points. Each gi is computed from {fm | i - floor(npts / 2) < m < i + floor(npts / 2)}, where npts is the value of the Points of Window variable. However, when the smoothing method is FFT filter, moving window is not used. Instead, the whole signal is processed.
The adjacent-averaging method performs the simplest possible averaging procedure: each gi is the average of the data points within the moving window. If the Weighted average option is used, the average will be computed using weighted averaging. In this case, a parabolic weight is used, with the weight area normalized to 1. For a window whose center is in i, the weight which corresponds to the jth (j=0, 1, ... npts-1) point is:
The Savitzky-Golay method performs a polynomial regression to the data points in the moving window. Then gi will be computed as the value of the polynomial at position i.
For the percentile filter, the pth quantile of the points in the moving window is assigned as gi, where p is specified by the parameter, Percentile. The pth quantile (or 100 pth percentile) is computed from the empirical distribution function as follows:
Let
where j is the integer part of
, and g is the fractional part of it.
Then we can compute the pth quantile, which is denoted by y, with the following equations:
where xj is the jth (j=0, 1, ... npts-1) point in the moving window.
When the FFT Filter method is selected, Origin performs the following:
The method used to construct the baseline depends on the baseline variable. If baseline is 0, this X-Function connects the first and last data points in the input data to form the baseline; If baseline is 1, it calculates the mean of the first 1% data points and the mean of the last 1% data points and then connects these mean values with a straight line.
The type of filter used in the filtering process depends on the filter variable. If filter is 0, the low-pass parabolic filter described in the Algorithm part of the X-Function document for FFT Filter will be used. Otherwise, the following window (which is used in Origin 7.5) will be used:
|
Note: In Origin 7.5, padding is always used and baseline subtraction always uses the two ends method. To achieve same results as in Origin 7.5, set pad to 1, filter to 1 and baseline to 0. |
For more information, please refer to our User Guide.