# Create an 2x2 correlation matrix
R = 0.5*diag(2) + 0.5
# Sample 1000 uncorrelated deviates from a
# bivariate standard normal distribution
X = matrix(rnorm(2*1000), ncol=2)
# Compute the transformation matrix
T = transMat(R)
# Apply the transformation to the deviates
Y = X%*%T
# Measure the sample correlation
cor(Y)
Run the code above in your browser using DataLab