Skip to content

Instantly share code, notes, and snippets.

@gwerbin
Created July 20, 2016 05:18
Show Gist options
  • Select an option

  • Save gwerbin/581cda166348889a1017552a3720fd23 to your computer and use it in GitHub Desktop.

Select an option

Save gwerbin/581cda166348889a1017552a3720fd23 to your computer and use it in GitHub Desktop.
#! /usr/bin/env Rscript
library(mvtnorm) # `install.packages('mvtnorm')`
set.seed(507734)
Y1 <- rmvnorm(n = 1e4, mu = c(9, 9), sigma = diag(2))
Y2 <- rmvnorm(n = 1e4, mu = c(18, 18), sigma = 4 * diag(2))
Y <- rbind(Y1, Y2)
detY1 <- det(cov(Y1))
detY2 <- det(cov(Y2))
detY <- det(cov(Y))
# empty plot command to set up the axes and labels
plot(0, type = 'n', xlim = c(0, 30), ylim = c(0, 30), xlab = "Dim 1", ylab = "Dim 2")
points(Y1, col = 'steelblue')
points(Y2, col = 'orange')
title(main = sprintf("|Y1| + |Y2| = %.2f + %.2f = %.2f\n|Y| = %.2f", detY1, detY2, detY1 + detY2, detY))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment