rvmean

rvmean(x)

Arguments

x

an rv object

Value

A numerical vector with the same dimension as x.

Details

rvmean computes the means of the simulations of all individual components of a random vector (rv) object.

E is an alias for rvmean, standing for "Expectation."

Pr is another alias for rvmean, standing for "Probability of"; suggested to be used when the argument is a logical statement involving random variables (that is, a description of an event such as x>0 or x>y). Then Pr(x>0) gives the probability of the event "x>0". The statement x>0 returns a Bernoulli (indicator) random variable object (having 1/0 or TRUE/FALSE values) and the expectation of such variable is just the probability of the event where the indicator is one.

References

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").

See also

mean.rv: distribution of the arithmetic mean of a vector; rvmin, rvmax, rvmedian, link{rvvar}, rvsd.

Author

Jouni Kerman jouni@kerman.com

Examples


  x <- rvnorm(mean=(1:10)/5, sd=1)
  rvmean(x)  # means of the 10 components
#>  [1] 0.2225613 0.3816966 0.4681305 0.9061587 1.0272147 1.1240712 1.3280164
#>  [8] 1.6543578 1.7914848 2.0070384
  E(x)       # same as rvmean(x)
#>  [1] 0.2225613 0.3816966 0.4681305 0.9061587 1.0272147 1.1240712 1.3280164
#>  [8] 1.6543578 1.7914848 2.0070384
  Pr(x>1)    # probabilities that each component is >1.
#>  [1] 0.235 0.280 0.330 0.440 0.505 0.565 0.635 0.745 0.805 0.830