Numeric Random Vectors

Description

Creates or coerces rv objects of type "numeric".

Usage

1
2
3
4
5
6
7
8
  ## S3 method for class 'rv'
is.numeric(x)
  ## S3 method for class 'rv'
as.numeric(x, ...)
  ## S3 method for class 'rvfactor'
is.numeric(x)
  ## S3 method for class 'rvfactor'
as.numeric(x, ...)

Arguments

x

an rv object to be coerced or tested.

...

further arguments passed to or from other methods.

Details

is.numeric(x) returns TRUE if and only if each component of x is numeric-valued.

as.numeric.rv coerces an rv object into numeric-valued one. In effect, the function as.numeric is applied to all simulations.

Random factors are not numeric (just as non-random factors aren't).

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

See Also

numeric.

Examples

1
2
3
4
  x <- as.logical(rvbern(1,0.5)) # Bernoulli rv
  is.numeric(x)           # FALSE
  x <- as.numeric(x)      # coerce to numeric; all TRUEs become ones, FALSEs zeros
  is.numeric(x)           # TRUE

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.