rnormmix | R Documentation |
Simulate from a mixture of univariate normal distributions.
rnormmix(n, lambda=1, mu=0, sigma=1)
n |
Number of cases to simulate. |
lambda |
Vector of mixture probabilities, with length equal to m, the desired number of components (subpopulations). This is assumed to sum to 1; if not, it is normalized. |
mu |
Vector of means. |
sigma |
Vector of standard deviations. |
This function simply calls rmvnormmix
.
rnormmix
returns an n-vector sampled from an m-component
mixture of univariate normal distributions.
makemultdata
, rmvnormmix
##Generate data from a 2-component mixture of normals. set.seed(100) n <- 500 lambda <- rep(1, 2)/2 mu <- c(0, 5) sigma <- rep(1, 2) mixnorm.data <- rnormmix(n, lambda, mu, sigma) ##A histogram of the simulated data. hist(mixnorm.data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.