simapply applies a given function FUN to each row of the simulation matrix, returning an rv object.

simapply(x, FUN, ...)

Arguments

x

a random vector.

FUN

a function.

...

further arguments passed to FUN.

Value

An rv object, representing the distribution of FUN(x, ...).

Details

simapply applies a given function to the rows of the simulation matrix of the given random vector.

If the function accepts arrays, use rvmapply instead.

If the function is to be applied to each component of the random vector separately (such as in rvmean), use rvsimapply instead.

Usually used in functions that implement an 'rv'-compatible numeric function.

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

Author

Jouni Kerman jouni@kerman.com

Examples


  #
  x <- rvnorm(10)
  simapply(x, mean) # Same result as that of mean(x).
#>       mean   sd    1% 2.5%   25%     50%  75% 97.5%  99% sims
#> [1] 0.0063 0.32 -0.66 -0.6 -0.23 0.00027 0.23  0.65 0.71  200