Learn R Programming

rv (version 0.949)

constant: Constant Vectors

Description

Tests or coerces objects that are non-random.

Usage

is.constant(x)
 ## S3 method for class 'rv':
is.constant(x)
 ## S3 method for class 'default':
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 the implied variance (sample variance of the simulations) is zero or if there is only one simulation (that is, the variable is ``constant").

References

Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York.

Examples

Run this code
is.constant(1)         # TRUE
  is.constant(as.rv(1))  # TRUE
  is.constant(rvnorm(1)) # FALSE

Run the code above in your browser using DataLab