Description Usage Arguments Details Value Functions Note Author(s) References See Also Examples
This function smoothes a numeric vector.
1 2 3 4 5 6 7 
x 

cf 

hws 

k 

For the SavitzkyGolayFilter the hws
should be smaller than
FWHM of the peaks (full width at half maximum; please find details in
Bromba and Ziegler 1981).
In general the hws
for the (weighted) moving average (coefMA
/coefWMA
)
has to bemuch smaller than for the SavitzkyGolayFilter to conserve the
peak shape.
smooth
: A numeric
of the same length as x
.
coefMA
: A matrix
with coefficients for a simple moving average.
coefWMA
: A matrix
with coefficients for a weighted moving average.
coefSG
: A matrix
with SavitzkyGolayFilter coefficients.
coefMA
: Simple Moving Average
This function calculates the coefficients for a simple moving average.
coefWMA
: Weighted Moving Average
This function calculates the coefficients for a weighted moving average with
weights depending on the distance from the center calculated as
1/2^abs(hws:hws)
with the sum of all weigths normalized to 1.
coefSG
: SavitzkyGolayFilter
This function calculates the SavitzkyGolayCoefficients. The additional
argument k
controls the order of the used polynomial. If k
is set to zero
it yield a simple moving average.
The hws
depends on the used method ((weighted) moving
average/SavitzkyGolay).
Sebastian Gibb, Sigurdur Smarason (weighted moving average)
A. Savitzky and M. J. Golay. 1964. Smoothing and differentiation of data by simplified least squares procedures. Analytical chemistry, 36(8), 16271639.
M. U. Bromba and H. Ziegler. 1981. Application hints for SavitzkyGolay digital smoothing filters. Analytical Chemistry, 53(11), 15831586.
Implementation based on: Steinier, J., Termonia, Y., & Deltour, J. (1972). Comments on Smoothing and differentiation of data by simplified least square procedure. Analytical Chemistry, 44(11), 19061909.
Other noise estimation and smoothing functions:
noise()
1 2 3 4 5 6 7 8 9 10  x < c(1:10, 9:1)
plot(x, type = "b", pch = 20)
cf < list(MovingAverage = coefMA(2),
WeightedMovingAverage = coefWMA(2),
SavitzkyGolay = coefSG(2))
for (i in seq_along(cf)) {
lines(smooth(x, cf[[i]]), col = i + 1, pch = 20, type = "b")
}
legend("bottom", legend = c("x", names(cf)), pch = 20,
col = seq_len(length(cf) + 1))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.