Skip to content

Instantly share code, notes, and snippets.

Last active December 16, 2015 07:48
What would you like to do?
Generalized/power mean with R
# Power mean
## Examples:
## p = 1, arithmetic mean
## p = 2, quadratic mean (RMS)
pmean <- function(x, p) {
return(tail(TTR::SMA(x^p, length(x))^(1/p), n=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment