as.logical.rv: Logical Random vectors

View source: R/rv.R

as.logical.rvR Documentation

Logical Random vectors

Description

Coerces a random variable to a logical-valued one (Bernoulli r.v.)

Usage

## S3 method for class 'rv'
as.logical(x, ...)

Arguments

x

an rv object

...

Further arguments passed on

Details

In effect, the function as.logical is applied to all simulations.

Note

is.logical(x) returns TRUE if and only if each component of x is logical-valued (i.e. TRUE/FALSE).

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


  x <- rvbern(prob=0.5)   # some 0/1 valued random variable
  print(x)
  is.logical(x)           # FALSE, because by default x is 'double'
  x <- as.logical(x)      # coerce to logical; all zeros become FALSE, ones become TRUE
  is.logical(x)           # TRUE
  print(x)                # Shows the expectations and not the quantiles


rv documentation built on March 18, 2022, 5:55 p.m.