Skip to content

Instantly share code, notes, and snippets.

@jyfeather
Created November 7, 2013 14:05
Show Gist options
  • Save jyfeather/7355039 to your computer and use it in GitHub Desktop.
Save jyfeather/7355039 to your computer and use it in GitHub Desktop.
library(mvtnorm)
x.points <- seq(-3,3,length.out=100) # generate a sequence
y.points <- x.points
z <- matrix(0, nrow=100, ncol=100)
mu <- c(1,1)
sigma <- matrix(c(2,1,1,1),nrow=2)
for (i in 1:100) {
for (j in 1:100) {
# multivariate normal density
z[i,j] <- dmvnorm(c(x.points[i],y.points[j]), mean=mu, sigma=sigma)
}
}
contour(x.points,y.points,z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment