Statistics: mvnpdf

### Function Reference: `mvnpdf`

statistics: y = mvnpdf (x, mu, sigma)

Multivariate normal probability density function (PDF).

`y = mvnpdf (x)` returns the probability density of the multivariate normal distribution with zero mean and identity covariance matrix, evaluated at each row of x. Rows of the N-by-D matrix x correspond to observations orpoints, and columns correspond to variables or coordinates. y is an N-by-1 vector.

`y = mvnpdf (x, mu)` returns the density of the multivariate normal distribution with mean MU and identity covariance matrix, evaluated at each row of x. mu is a 1-by-D vector, or an N-by-D matrix, in which case the density is evaluated for each row of x with the corresponding row of mu. mu can also be a scalar value, which MVNPDF replicates to match the size of x.

`y = mvnpdf (x, mu, sigma)` returns the density of the multivariate normal distribution with mean mu and covariance sigma, evaluated at each row of x. sigma is a D-by-D matrix, or an D-by-D-by-N array, in which case the density is evaluated for each row of x with the corresponding page of sigma, i.e., `mvnpdf` computes y(i) using x(i,:) and sigma(:,:,i). If the covariance matrix is diagonal, containing variances along the diagonal and zero covariances off the diagonal, sigma may also be specified as a 1-by-D matrix or a 1-by-D-by-N array, containing just the diagonal. Pass in the empty matrix for mu to use its default value when you want to only specify sigma.

If x is a 1-by-D vector, `mvnpdf` replicates it to match the leading dimension of mu or the trailing dimension of sigma.

See also: mvncdf, mvnrnd

Source Code: mvnpdf

### Example: 1

     mu = [1, -1];
     sigma = [0.9, 0.4; 0.4, 0.3];
     [X1, X2] = meshgrid (linspace (-1, 3, 25)', linspace (-3, 1, 25)');
     x = [X1(:), X2(:)];
     p = mvnpdf (x, mu, sigma);
     surf (X1, X2, reshape (p, 25, 25));