sgolay_robust

版本 0.1.0 (384.6 KB) 作者: phenan08
A Savitzky-Golay filter with robust options, that can be used for various applications, such as baseline correction, outlier detection...
23.0 次下载
更新时间 2023/7/14

sgolay_robust

A Savitzky-Golay filter with robust options

sgolay_robust is a MATLAB script that permits to smooth data thanks to local polynomial regressions based on the iteratively-reweighted least square (IRLS) procedure. The IRLS method minimizes the influence of outliers using Bisquare weighting.

The filter can be used for various applications, such as anomaly detection, baseline correction, peak detection...

The general syntax is:

[output_1, output_2] = sgolay_robust(input_data,frame_half_length,order,evaluation_interval,options)

where:

  • input_data is a vector of real numbers (i.e. the data to smooth.)
  • frame_half_length is a scalar positive integer that specifies the half-length of the filter frame. If the value equals 10, the filter will operate on each value of input_data using 21 values (the 10 previous values, the 10 subsequent values and the value itself).
  • order is a scalar positive or null integer that specifies the polynomial order for the filter.
  • evaluation_interval is a scalar positive integer that specifies the interval for which the filter operates. When set to 1, the filter smoothes the data on every value. When set to 10, the filter smoothes the data every 10 points, and evaluates the intermediate values by interpolation.
  • options: optional name-values arguments
    • interpolation_method: a scalar string that specifies the interpolation method, in case evaluation_interval is larger than 1. The possible interpolation methods are "linear" (default), "cubic", "spline" and "makima".
    • display_warning: a scalar string that specifies whether or not the console should display warning messages.
    • TolFun: a scalar positive double that specifies the stopping threshold in the change of the objective function value during the IRLS procedure. The default value is 1e-3.
    • TolX: a scalar positive double that specifies the stopping threshold in the change of the polynomial coefficients during the IRLS procedure. The default value is 1e-3.
    • MaxIter: a scalar positive integer that specifies the maximum allowed iterations for the IRLS procedure. The default value is 200.

The two returned outputs are:

  • output_1: the smoothed data
  • output_2: the local robust standard deviation of the smoothed data

Examples of function calls:

  • [y0, s] = sgolay_robust(y,10,2,1)
  • [y0, s] = sgolay_robust(y,10,2,10,"interpolation_method","makima")
  • [y0, s] = sgolay_robust(y,10,2,10,"interpolation_method","makima","MaxIter",50)

Warning

The parameters of the filter should be appropriately set to avoid overfitting. Using a large polynomial order value is therefore not a good idea, even if the script performs a certain regularization of the data during the IRLS procedure (matrix inversion according to Moore-Penrose).

Examples

Examples are provided here.

Disclaimer

Author: Antoine BUREL

The script is licensed under the CC0 1.0 Universal terms. See the LICENSE file.

The author accepts no responsibility for the use of the script.

引用格式

phenan08 (2024). sgolay_robust (https://github.com/burelant/sgolay_robust/releases/tag/v0.1.0), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2023a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
0.1.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库