rnormmix | R Documentation |
Generate random samples from a normal mixture model.
rnormmix(n, prop, mu, sigma)
n |
number of observations. |
prop |
a vector of proportions of different components. |
mu |
a vector of means of different components. |
sigma |
a vector of standard deviations of different components |
A matrix with each row corresponding to one sample. The first column are sample values from a normal mixture model; the second column are the components from which observations come.
prop <- c(.17, .48, .35) mu <- c(-4, 0, 4) sigma <- rep(1, 3) y <- rnormmix(n=10000, prop, mu, sigma) densityplot(~ y[,1], groups = y[,2], plot.points = FALSE, ref = TRUE, xlab="sample values", auto.key = list(columns = 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.