Skip to contents

Smooth data in vector x to its endpoint.

Usage

box_smooth(x, box_width = 28)

Arguments

x

1D data to be smoothed.

box_width

Width (in units of vector steps) of the box used for smoothing.

Value

x_smooth Smoothened version of x.

Details

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.

Examples

# 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)