rmixnorm {gratis} | R Documentation |
Generate random variables from a mixture of multivariate normal distributions
Description
Random variables from a mixture of k multivariate normal distributions, each of dimension q.
Usage
rmixnorm(n, means, sigmas, weights)
Arguments
n |
an integer for the number of samples to be generated. |
means |
a q x k matrix (or a vector of length k if q=1) containing the means for each component. |
sigmas |
a q x q x k covariance array (or a vector of length k if q=1) for each component. |
weights |
a vector of length k containing the weights for each component. |
Value
An n x q matrix (or a vector if q=1) containing the generated data.
Author(s)
Feng Li, Central University of Finance and Economics.
References
Villani et al 2009.
Examples
out <- rmixnorm(
n = 1000, means = c(-5, 0, 5), sigmas = c(1, 1, 3),
weights = c(0.3, 0.4, 0.3)
)
hist(out, breaks = 100, freq = FALSE)
[Package gratis version 1.0.7 Index]