powered by
Smooth data in vector x to its endpoint.
box_smooth(x, box_width = 28)
x_smooth Smoothened version of x.
1D data to be smoothed.
Width (in units of vector steps) of the box used for smoothing.
Employ an endpoint box filter (aka "running mean" or endpoint smoother) to the 1-D data in x:
x_smoothed[i] = mean(x[i-box_width:i])
Where x is considered to be zero-padded vor values of i-box_width < 1.
# Create a sine wave with noise x = seq(0, 4*pi, 0.1) y = sin(x) + runif(length(x)) # Apply endpoint smoothing y_smooth = box_smooth(y, box_width = 5)
Run the code above in your browser using DataLab