as.logical.rv | R Documentation |
Coerces a random variable to a logical-valued one (Bernoulli r.v.)
## S3 method for class 'rv' as.logical(x, ...)
x |
an rv object |
... |
Further arguments passed on |
In effect, the function as.logical
is applied to all simulations.
is.logical(x)
returns TRUE
if and only if each
component of x
is logical-valued (i.e. TRUE
/FALSE
).
Jouni Kerman jouni@kerman.com
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")
.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.