constant {rv}R Documentation

Constant Vectors

Description

Tests or coerces objects that are non-random.

Usage

 is.constant(x)
 as.constant(x)
 ## S3 method for class 'rv':
 as.constant(x)

Arguments

x an object, random variable (rv) or not

Details

is.constant returns TRUE for each component of the argument object if there is only one simulation (that is, the variable is ``constant").

Note: rv objects that merely have variance zero are not therefore necessarily constants.

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

  is.constant(1)         # TRUE
  is.constant(as.rv(1))  # TRUE
  setnsims(200)
  x <- rvbern(prob=0.001)
  all(sims(x)==0)        # most probably true
  is.constant(x)         # always FALSE

[Package rv version 1.0 Index]