Learn R Programming

MixtureInf (version 1.1)

rmix.norm: generate a random sample from a mixture of normals

Description

Generate a random sample from a mixture of normals.

Usage

rmix.norm(n, alpha, mu, sigma = rep(1,length(alpha)))

Arguments

n
sample size.
alpha
vector of mixture proportions of length m, the order of the mixture.
mu
vector of means of component distributions.
sigma
vector of standard deviations of component distributions, default value: sigma = rep(1,length(alpha)).

Value

Return a samples of size n from an m-component normal mixture.

See Also

emtest.norm, emtest.norm0, plotmix.norm, plotmix.norm0, pmle.norm, pmle.norm0

Examples

Run this code
#generate a random sample from a 2 component normal mixture,
#plot the histogram of the data.
x <- rmix.norm(200,c(0.3,0.7),c(-1,2),c(1,2))
hist(x)

Run the code above in your browser using DataLab