### Number of components
K <- 5
### Dimension
p <- 2
### Number of observations
n <- 200
Mu <- matrix(runif(K*p, 0, 20), K, p)
Sigma <- array(0, c(K, p, p))
for (k in 1:K)
{
Sigma[k,,][outer(1:p, 1:p, ">")] <- runif(p*(p-1)/2,-.1,.1)
diag(Sigma[k,,]) <- runif(p,0,1)
### Make sigma positive definite
Sigma[k,,] <- Sigma[k,,] %*% t(Sigma[k,,])
}
### Generate the weights
w <- rgamma(K,10,1)
w <- w/sum(w)
y <- SimulateMixture(n, w, Mu, Sigma, nu=4)
Run the code above in your browser using DataLab