library(mvtnorm)
library(matlib)

The ggplot2 package [46] is for plotting. Then, we define the mean and the standard deviation as:

## Standard deviation
sigma <- matrix(c(4,2,2,3), ncol = 2, nrow = 2)
## Mean
mu <- c(1, 2)

For this data we have the sample size n = 10000.

n <- 1000

The function set.seed() sets the seed, which is a value to start generating random numbers. The set.seed() function resets the values of the random numbers and random functions from the values previously obtained. We set a seed in order to reproduce the same outcome. If we set the same seed, then we can reproduce the same random numbers:

set.seed(123)

Finally, we generate the data points by

x <- rmvnorm(n = n, mean = mu, sigma = sigma)

To plot the data we set the points in a data frame:

d <- data.frame(x)

Using the ggplot2 package we plot the data points as

y <- x - mu
E <- eigen(sigma)
E$vectors
##            [,1]       [,2]
## [1,] -0.7882054  0.6154122
## [2,] -0.6154122 -0.7882054