Displaying 1 result from an estimated 1 matches for "xy_val".
Did you mean:
py_val
2018 Apr 12
3
Bivariate Normal Distribution Plots
...sig_xy <- rho_xy * sig_x *sig_y
# Covariance matrix
Sigma_xy <- matrix(c(sig_x ^ 2, sig_xy, sig_xy, sig_y ^ 2), nrow = 2, ncol = 2)
# Load the mvtnorm package
library("mvtnorm")
# Means
mu_x <- 0
mu_y <- 0
# Simulate 1000 observations
set.seed(12345) # for reproducibility
xy_vals <- rmvnorm(1000, mean = c(mu_x, mu_y), sigma = Sigma_xy)
# Have a look at the first observations
head(xy_vals)
# Create scatterplot
plot(xy_vals[, 1], xy_vals[, 2], pch = 16, cex = 2, col = "blue",
main = "Bivariate normal: rho = 0.0", xlab = "x", ylab = &...