rvnsims {rv}R Documentation

Number of simulations stored in each component of an rv object

Description

rvnsims returns the number of simulations stored in each component of its argument; setnsims sets the default number of simulations; getnsims retrieves the default number of simulations.

Usage

  rvnsims(x)
  setnsims(n.sims)
  getnsims()

Arguments

x an rv object.
n.sims default number of simulations; must be at least 2.

Details

If the argument is a non-rv numeric vector, rvnsims returns 1 (corresponding to a `constant') for each component.

The minimum number of default simulations is 2.

Value

rvnsims: a vector of integers.
setnsims: previously set default number of simulations.
getnsims: (integer) currently set default number of simulations.

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

  #
  rvnsims(1.23)             # 1
  x <- rvnorm(1)            # an rv
  rvnsims(x)                # equal to setnsims()
  rvnsims(x)==nrow(sims(x)) # TRUE
  rvnsims(x)==getnsims()    # TRUE
  setnsims(1000)            # set n.sims to 1000
  n.sims <- setnsims(10000) # s is now 1000
  print(getnsims())         # prints 10000
  setnsims(n.sims)          # restore the number of simulations back to 1000

[Package rv version 1.0 Index]