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.

rvnsims(x)

Arguments

x

an rv object.

Value

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

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.

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


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