开始使用免费开始使用

Calculating the density of multivariate normal

For many statistical tasks, like hypothesis testing, clustering, and likelihood calculation, you are required to calculate the density of a specified multivariate normal distribution. In this exercise, you will use the dmvnorm() function to calculate multivariate normal densities with specified mean and variance-covariance matrix at each of the observations from your previously generated sample multnorm.sample.

The mean and the variance-covariance matrix are preloaded for you as objects mu.sim and sigma.sim.

本练习是课程的一部分

Multivariate Probability Distributions in R

查看课程

练习说明

  • Use dmvnorm() to calculate the density heights of the 100 samples in multnorm.sample for a bivariate normal.
  • Use scatterplot3d() to plot a 3D scatterplot of the density heights at each of the generated sample points.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Calculate density
multnorm.dens <- dmvnorm(multnorm.sample, mean = ___, sigma = ___)

# Create scatter plot of density heights 
___(cbind(___),    
               color="blue", pch="", type = "h",             
                              xlab = "x", ylab = "y", zlab = "density")
编辑并运行代码