# # first simulated data set in R # library(mva) # generate the data: normal distributions data <- cbind(rnorm(1000),rnorm(1000)) # set the covariance and mean sigma <- cbind(c(2,1),c(1,2)) m <- c(-5,5) ones <- matrix( c(rep(1,1000), rep(1,1000)), ncol=2) # rotate the data r <- chol(sigma) data.r <- data %*% r # shift the data data.r.s <- data.r + (ones %*% diag(m)) par( mfrow = c(2,2), pty = "s") plot(data, pch=".", xlim=c(-10,10), ylim=c(-10,10)) plot(data.r, pch=".", xlim=c(-10,10), ylim=c(-10,10)) plot(data.r.s, pch=".", xlim=c(-10,10), ylim=c(-10,10)) data.r.s.pca <- prcomp(data.r.s) plot(data.r.s.pca$x, pch=".", xlim=c(-10,10), ylim=c(-10,10))