Smooth values using a Savitzky-Golay filter. This function is suitable for not equally-spaced and/or weighted data.
w_savgol(y, x, q, window = 7, polynom = 3)List of floats representing the "y" values.
List of floats representing the "x" values of the data.
Must have same length as y.
If missing, points are assumed to be equally-spaced
List of floats representing the relative weight of "y" values.
Must have same length as y.
If missing, all points are assumed to have the same weight.
Window length of datapoints.
Must be odd and smaller than x. Default is 7.
The polynomial order to be used.
Must be smaller than the window size. Default is 3.
The smoothed "y" values.
This is an R adaptation of Python function at https://dsp.stackexchange.com/questions/1676/savitzky-golay-smoothing-filter-for-not-equally-spaced-data, with the addition of weights following https://en.wikipedia.org/wiki/Savitzky-Golay_filter.