simapply: Apply a Function to Rows of Simulations of Random Vectors

View source: R/simapply_rv.R

simapplyR Documentation

Apply a Function to Rows of Simulations of Random Vectors

Description

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

Usage

simapply(x, FUN, ...)

Arguments

x

a random vector.

FUN

a function.

...

further arguments passed to FUN.

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.

Value

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

Author(s)

Jouni Kerman jouni@kerman.com

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

Examples


  #
  x <- rvnorm(10)
  simapply(x, mean) # Same result as that of mean(x).


rv documentation built on March 18, 2022, 5:55 p.m.