mean.rv
computes the distribution of the arithmetic average of its
argument rv
object.
# S3 method for rv
mean(x, ...)
an object
further arguments passed to or from other methods
mean
gives the distribution (that is, a random variable object) of
the statistic \(\frac{1}{n}\sum_{i=1}^n x_i\)
(sum(x)/length(x)
).
In particular, mean(x)
of a random vector x
of length one is
equal to x
as it would be in the case of numerical x.
To find the expectation of a random vector x
(that is, the individual
means of random components in a vector), use rvmean(x)
(same as
E(x)
and Pr(x)
).
Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.
See also vignette("rv")
.
y <- rvnorm(10, mean=0, sd=1)
m1 <- mean(y)
m2 <- rvnorm(1, mean=0, sd=1/sqrt(10))
print(c(m1, m2)) # should have the same distribution
#> mean sd 1% 2.5% 25% 50% 75% 97.5% 99% sims
#> [1] -0.0099 0.34 -0.75 -0.61 -0.25 -0.016 0.26 0.62 0.66 200
#> [2] -0.0393 0.31 -0.72 -0.66 -0.23 -0.055 0.15 0.56 0.80 200