rvar-dist {posterior} | R Documentation |
Density, CDF, and quantile functions of random variables
Description
The probability density function (density()
), cumulative distribution
function (cdf()
), and quantile function / inverse CDF (quantile()
) of
an rvar
.
Usage
## S3 method for class 'rvar'
density(x, at, ...)
## S3 method for class 'rvar_factor'
density(x, at, ...)
## S3 method for class 'rvar'
cdf(x, q, ...)
## S3 method for class 'rvar_factor'
cdf(x, q, ...)
## S3 method for class 'rvar_ordered'
cdf(x, q, ...)
## S3 method for class 'rvar'
quantile(x, probs, ...)
## S3 method for class 'rvar_factor'
quantile(x, probs, ...)
## S3 method for class 'rvar_ordered'
quantile(x, probs, ...)
Arguments
x |
(rvar) An |
... |
Additional arguments passed onto underlying methods:
|
q , at |
(numeric vector) One or more quantiles. |
probs |
(numeric vector) One or more probabilities in |
Value
If x
is a scalar rvar
, returns a vector of the same length as the input
(q
, at
, or probs
) containing values from the corresponding function
of the given rvar
.
If x
has length greater than 1, returns an array with dimensions
c(length(y), dim(x))
where y
is q
, at
, or probs
, where each
result[i,...]
is the value of the corresponding function,f(y[i])
, for
the corresponding cell in the input array, x[...]
.
Examples
set.seed(1234)
x = rvar(rnorm(100))
density(x, seq(-2, 2, length.out = 10))
cdf(x, seq(-2, 2, length.out = 10))
quantile(x, ppoints(10))
x2 = c(rvar(rnorm(100, mean = -0.5)), rvar(rnorm(100, mean = 0.5)))
density(x2, seq(-2, 2, length.out = 10))
cdf(x2, seq(-2, 2, length.out = 10))
quantile(x2, ppoints(10))