| mvdist | R Documentation |
Random generation for common multivariate distributions. All functions
return an n x d matrix with column names, and accept an optional seed.
r_mvnorm(): multivariate normal N(\mu, \Sigma).
r_mvt(): multivariate Student-t with df degrees of freedom and
scale matrix sigma.
r_mvlnorm(): multivariate log-normal: exp() of a multivariate normal
with parameters meanlog, sigmalog.
r_mvskewnorm(): multivariate skew-normal of Azzalini and Dalla Valle
(1996) with location xi, scale matrix omega and shape alpha.
r_dirichlet(): Dirichlet distribution on the simplex, generated by
normalising gamma draws. Draws are computed on the log scale (with the
Y U^{1/a} boost for shapes below 1), so very small concentration
parameters do not underflow to 0/0; as \alpha \to 0 the draws
approach the vertices of the simplex.
r_mvmixture(): finite mixture of multivariate normals.
r_mvnorm(n, mean = NULL, sigma, seed = NULL)
r_mvt(n, df, mean = NULL, sigma, seed = NULL)
r_mvlnorm(n, meanlog = NULL, sigmalog, seed = NULL)
r_mvskewnorm(n, xi = NULL, omega, alpha, seed = NULL)
r_dirichlet(n, alpha, seed = NULL)
r_mvmixture(n, weights, means, sigmas, return_component = FALSE, seed = NULL)
n |
Number of draws. |
mean, xi |
Mean / location vector (finite; defaults to zero). |
sigma, omega |
Covariance (scale) matrix: square, finite, symmetric
and positive semi-definite. |
seed |
Optional random seed. |
df |
Degrees of freedom ( |
meanlog, sigmalog |
Mean vector and covariance matrix on the log scale. |
alpha |
Shape (skewness) vector for |
weights |
Mixture weights (normalised internally). |
means |
List of component mean vectors. |
sigmas |
List of component covariance matrices. |
return_component |
Should |
A numeric matrix with n rows.
Azzalini, A. and Dalla Valle, A. (1996). The multivariate skew-normal distribution. Biometrika, 83(4), 715–726. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/biomet/83.4.715")}
S <- make_corr(3, "ar1", 0.6)
x <- r_mvnorm(1000, mean = c(0, 1, 2), sigma = S, seed = 1)
round(cor(x), 2)
t3 <- r_mvt(500, df = 3, sigma = S)
sn <- r_mvskewnorm(500, omega = S, alpha = c(5, 0, -5))
dir <- r_dirichlet(5, alpha = c(1, 2, 3))
rowSums(dir)
mix <- r_mvmixture(500, weights = c(0.3, 0.7),
means = list(c(-2, -2), c(2, 2)),
sigmas = list(diag(2), diag(2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.