| rvar-summaries-within-draws {posterior} | R Documentation |
Summaries of random variables over array elements, within draws
Description
Compute summaries of random variables over array elements and within draws,
producing a new random variable of length 1 (except in the case of
rvar_range(), see Details).
Usage
rvar_mean(..., na.rm = FALSE)
rvar_median(..., na.rm = FALSE)
rvar_sum(..., na.rm = FALSE)
rvar_prod(..., na.rm = FALSE)
rvar_min(..., na.rm = FALSE)
rvar_max(..., na.rm = FALSE)
rvar_sd(..., na.rm = FALSE)
rvar_var(..., na.rm = FALSE)
rvar_mad(..., constant = 1.4826, na.rm = FALSE)
rvar_range(..., na.rm = FALSE)
rvar_quantile(..., probs, names = FALSE, na.rm = FALSE)
rvar_all(..., na.rm = FALSE)
rvar_any(..., na.rm = FALSE)
Arguments
... |
(rvar) One or more |
na.rm |
(logical) Should |
constant |
(scalar real) For |
probs |
(numeric vector) For |
names |
(logical) For |
Details
These functions compute statistics within each draw of the random variable. For summaries over draws (such as expectations), see rvar-summaries-over-draws.
Each function defined here corresponds to the base function of the same name
without the rvar_ prefix (e.g., rvar_mean() calls mean() under the hood, etc).
Value
An rvar of length 1 (for range(), length 2; for quantile(), length
equal to length(probs)) with the same number
of draws as the input rvar(s) containing the summary statistic computed within
each draw of the input rvar(s).
See Also
rvar-summaries-over-draws for summary functions across draws (e.g. expectations). rvar-dist for density, CDF, and quantile functions of random variables.
Other rvar-summaries:
rvar-summaries-over-draws,
rvar_is_finite()
Examples
set.seed(5678)
x = rvar_rng(rnorm, 4, mean = 1:4, sd = 2)
# These will give similar results to mean(1:4),
# median(1:4), sum(1:4), prod(1:4), etc
rvar_mean(x)
rvar_median(x)
rvar_sum(x)
rvar_prod(x)
rvar_range(x)
rvar_quantile(x, probs = c(0.25, 0.5, 0.75), names = TRUE)