rnormmix {mixtools} | R Documentation |
Simulate from Mixtures of Normals
Description
Simulate from a mixture of univariate normal distributions.
Usage
rnormmix(n, lambda=1, mu=0, sigma=1)
Arguments
n |
Number of cases to simulate. |
lambda |
Vector of mixture probabilities, with length equal to |
mu |
Vector of means. |
sigma |
Vector of standard deviations. |
Details
This function simply calls rmvnormmix
.
Value
rnormmix
returns an n
-vector sampled from an m
-component
mixture of univariate normal distributions.
See Also
Examples
##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)
[Package mixtools version 2.0.0 Index]