1. Learn
  2. /
  3. Courses
  4. /
  5. Multivariate Probability Distributions in R

Exercise

Calculating dmvnorm over a grid

To visualize a bivariate normal density surface, one has to calculate the density over a dense grid of x and y coordinates, and use 3D surface plotting functions like persp() to visualize the surface.

The 40 by 40 dense grid generated from the command mvals <- expand.grid(seq(-5, 10, length.out = 40), seq(-8, 4, length.out = 40)) is preloaded for you.

Instructions

100 XP
  • Calculate the densities of a normal with the mean mu.sim and variance-covariance matrix sigma.sim on the grid values in the object mvals.
  • Use the persp() plot function to visualize the density surface over the grid.