RMS: Trimmed root mean square (RMS)

View source: R/utilities.R

RMSR Documentation

Trimmed root mean square (RMS)

Description

Calculates the root mean square of a sequence, which is defined as the square-root of the squared arithmetic mean.

Usage

RMS(x, trim = 0, na.rm = TRUE)

colRMS(x, na.rm = TRUE, ...)

rowRMS(x, na.rm = TRUE, ...)

Arguments

x

[from mean:] An R object. Complex vectors are allowed for trim = 0, only.

trim

numeric; [from mean:] the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint. Note that any trimming occurs prior to calculation of arithmetic mean.

na.rm

[from mean:] a logical value indicating whether NA values should be stripped before the computation proceeds.

...

additional parameters given to either rowMeans, or colMeans

Details

The functions rowRMS and colRMS cannot accept trim arguments because they use rowMeans and colMeans, respectively.

References

[1] http://en.wikipedia.org/wiki/Root_mean_square

See Also

Other utilities: list.txtgz(), norms(), pbo_message()

Examples

x <- sin(seq(-pi,pi,by=0.05))
xr <- RMS(x)
# this:
RMS(c(4,9))
# should equal ~6.96
#
# The expected value for a default \code{sin} curve is sqrt(2)/2
plot(x, type="l")
lines(abs(x), col="red")
abline(h=c(mean(x), mean(abs(x)), sqrt(2)/2, xr), lty=4:1, col=4:1)
#
M <- matrix(1:12,3)
colRMS(M)
rowRMS(M)

abarbour/pborepo documentation built on April 27, 2022, 8:47 a.m.