meanbp | R Documentation |
Moving average (weighted) per iteration
meanbp(vector, it = 1000, na.rm = T)
vector |
: a vector |
it |
: numbre of iterations |
na.rm |
: for ignore missing values |
This function returns an average whose values are weighted according to the distance that separates them from the median initially, and then, at each cycle, with respect to the "average" calculated in the previous cycle.
x <- rnorm(100,20,5) # simulate a sample of a population with an average of 20%.
meanbp(x,100) # 100 because the calculation will only be repeated a maximum of 100 times.
#if we compare with mean(x) or median(x):
# we see that meanbp gives a result closer to the true average which is 20
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.