if (FALSE) {
set.seed(1234)
repeat{
Q <- MixSim(BarOmega = 0.01, K = 4, p = 2)
if (Q$fail == 0) break
}
# simulate a dataset of size 300 and add 10 outliers simulated on (0,1)x(0,1)
A <- simdataset(n = 500, Pi = Q$Pi, Mu = Q$Mu, S = Q$S, n.out = 10, int = c(0, 1))
colors <- c("red", "green", "blue", "brown", "magenta")
plot(A$X, xlab = "x1", ylab = "x2", type = "n")
for (k in 0:4){
points(A$X[A$id == k, ], col = colors[k+1], pch = 19, cex = 0.5)
}
repeat{
Q <- MixSim(MaxOmega = 0.1, K = 4, p = 1)
if (Q$fail == 0) break
}
# simulate a dataset of size 300 with 1 noise variable
A <- simdataset(n = 300, Pi = Q$Pi, Mu = Q$Mu, S = Q$S, n.noise = 1)
plot(A$X, xlab = "x1", ylab = "x2", type = "n")
for (k in 1:4){
points(A$X[A$id == k, ], col = colors[k+1], pch = 19, cex = 0.5)
}
}
Run the code above in your browser using DataLab