主要内容

mvnpdf

多变量正常概率密度函数

Description

例子

y=mvnpdf(X的)returns anN.-by-1V.ectory包含概率密度函数(PDF)值D.-D.imensional multivariate normal distribution with zero mean and identity covariance matrix, evaluated at each row of theN.-by-D.矩阵X。For more information, see多变量正态分布

例子

y=mvnpdf(X的)returns pdf values of points inX那whereD.etermines the mean of each associated multivariate normal distribution.

例子

y=mvnpdf(XSigma的)returns pdf values of points inX那whereSigma确定每个相关多变量正态分布的协方差。

指定[]为了只要只使用其默认值为零Sigma

Examples

全部收缩

Evaluate the pdf of a standard five-dimensional normal distribution at a set of random points.

Randomly sample eight points from the standard five-dimensional normal distribution.

亩=zeros(1,5); Sigma = eye(5); rng('default'的)%的再现性X=mvnrnd(mu,Sigma,8)
X=8×50.5377 3.5784 -0.1241 0.4889 -1.0689 1.8339 2.7694 1.4897 1.0347 -0.8095 -2.2588 -1.3499 1.4090 0.7269 -2.9443 0.8622 3.0349 1.4172 -0.3034 1.4384 0.3188 0.7254 0.6715 0.2939 0.3252 -1.3077 -0.0631 -1.2075 -0.7873 -0.7549 -0.4336 0.7147 0.7172 0.8884 1.3703 0.3426  -0.2050 1.6302 -1.1471 -1.7115

评估点的分布的PDFX

y=mvnpdf(X)
y=8×10.0000 0.0000 0.0000 0.0000 0.0054 0.0011 0.0015 0.0003

Find the point inXwith the greatest pdf value.

[maxpdf,idx] = max(y)
maxpdf = 0.0054.
idx = 5
maxpoint = x(idx,:)
maxpoint =1×50.3188 0.7254 0.6715 0.2939 0.3252

The fifth point inX具有比任何其他随机选择的点的PDF值更大。

创建六个三维正常分布,每个分布都有明显的含义。评估不同随机点处的每个分布的PDF。

指定均值sand covariancesSigmaof the distributions. Each distribution has the same covariance matrix—the identity matrix.

FirstDim = (1:6)'; mu = repmat(firstDim,1,3)
亩=6×31112223 3 3 4 4 4 5 5 5 6 6 6
Sigma = Eye(3)
Sigma =3×31 0 0 0 1 0 0 0 1

Randomly sample once from each of the six distributions.

rng('default'的)%的再现性X=mvnrnd(mu,Sigma)
X=6×31.5377 0.5664 1.7254 3.8339 2.3426 1.9369 0.7412 6.5784 3.7147 4.8622 6.7694 3.7950 3.7950 5.3188 3.6501 4.8759 4.6923 7.6923 7.6923 7.6923 7.6923 7.6929 7.4897 7.4897

评估点的分布的PDFX。The pdf of the first distribution is evaluated at the pointx(1,:)那the pdf of the second distribution is evaluated at the pointX(2那:的), 和so on.

y = mvnpdf (X,μ的)
y=6×10.0384 0.0111 0.0000 0.0009 0.0241 0.0001

评估一组给定点的二维正态分布的PDF。

指定均值and covarianceSigma分布。

亩=[1 -1]; Sigma = [0.9 0.4; 0.4 0.3];

随机样本从分布100次。指定X作为采样点的矩阵。

rng('default'的)%的再现性X=mvnrnd(mu,Sigma,100);

评估点的分布的PDFX

y = mvnpdf (X,μ那Sigma);

Plot the probability density values.

散射3(x(:,1),x(:,2),y)xlabel('X1'的)ylabel('X2')Zlabel('Probability Density'的)

图包含轴对象。轴对象包含类型分散的对象。

Create ten different five-dimensional normal distributions, and compare the values of their pdfs at a specified point.

设置尺寸N.andD.equal to 10 and 5, respectively.

n = 10;d = 5;

指定均值sand the covariancesSigmaof the multivariate normal distributions. Let all the distributions have the same mean vector, but vary the covariance matrices.

亩=ones(1,d)
亩=1×511111
mat =眼睛(d);nmat = repmat(mat,1,1,n);var =重塑(1:n,1,1,n);sigma = nmat。* var;

Display the first two covariance matrices inSigma

西格玛(::,1:2)
ans = ans(:,:,1)= 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ans(:,2)= 2 0 0 0 00 2 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 0 0 2

X在五维空间中是一个随机点。

rng('default'的)%的再现性X=N.ormrnd(0,1,1,5)
X=1×50.5377 1.8339 -2.2588 0.8622 0.3188

Evaluate the pdf atX为每个十分布。

y=mvnpdf(x,mu,Sigma)
y=10×110-4×0.2490 0.8867 0.8755 0.7035 0.5438 0.4211 0.3305 0.2635 0.2134 0.1753

Plot the results.

scatter(1:n,y,'填充'的)Xlabel('Distribution Index'的)ylabel('Probability Density at x'的)

图包含轴对象。轴对象包含类型分散的对象。

输入参数

全部收缩

评估点,指定为a1-by-D.数字矢量or anN.-by-D.数字矩阵那whereN.is a positive scalar integer andD.is the dimension of a single multivariate normal distribution. The rows ofXcorrespond to observations (or points), and the columns correspond to variables (or coordinates).

如果X是一个矢量,然后mvnpdf复制它以匹配领先的维度or the trailing dimension ofSigma

Data Types:single|D.ouble

Means of multivariate normal distributions, specified as a1-by-D.数字矢量or anN.-by-D.数字矩阵。

  • 如果是一个矢量,然后mvnpdfreplicates the vector to match the trailing dimension ofSigma

  • 如果是一个矩阵,然后是每行是单个多变量正态分布的平均矢量。

Data Types:single|D.ouble

多元正态分布的协方差那specified as aD.-by-D.对称,正定的矩阵or aD.-by-D.-by-N.数字数组。

  • 如果Sigma是一个矩阵,thenmvnpdfreplicates the matrix to match the number of rows in

  • 如果Sigmais an array, then each page ofSigmaSigma(:,:,i),是单个多变量正态分布的协方差矩阵,因此,是对称的正定矩阵。

如果协方差矩阵是对角线的,则沿着对角线和零考核的差异,那么您还可以指定Sigmaas a1-by-D.矢量或a1-by-D.-by-N.array containing just the diagonal entries.

Data Types:single|D.ouble

Output Arguments

全部收缩

pdf values, returned as anN.-by-1数字矢量,在哪里N.is one of the following:

  • Number of rows inX如果Xis a matrix

  • 次数X复制if.Xis a vector

如果X是一个矩阵,是一个矩阵,andSigmais an array, thenmvnpdfcomputesy(i)usingX(i,:)亩(i,:), 和Sigma(:,:,i)

Data Types:D.ouble

更多关于

全部收缩

多变量正态分布

多变量正态分布是单变量正常分布到两个或多个变量的概括。它有两个参数,平均矢量μ和协方差矩阵Σ,这类似于单变量正态分布的平均值和方差参数。对角线元素Σ包含每个变量的差异,以及偏差元素Σcontain the covariances between variables.

The probability density function (pdf) of theD.- 多维多元正态分布是

y = F X μ Σ 的) = 1 | Σ | (2 π 的) D. exp 1 2 X - μ 的) Σ -1 X - μ ' 的)

whereXandμare 1-by-D.V.ectors andΣis aD.-by-D.对称,正定的矩阵。Onlymvnrndallows positive semi-definiteΣ矩阵,可以是单数。PDF不能有相同的形式Σ是单数的。

The multivariate normal cumulative distribution function (cdf) evaluated atX是随机矢量的概率V.那D.istributed as multivariate normal, lies within the semi-infinite rectangle with upper limits defined byX

Pr { V. 1 的) X 1 的) V. 2 的) X 2 的) 。。。 V. D. 的) X D. 的) }

Although the multivariate normal cdf does not have a closed form,mvncdfcan compute cdf values numerically.

Tips

  • 在一维案例中,Sigma是方差,而不是标准偏差。例如,mvnpdf(1,0,4)是相同的诺普德夫(1,0,2)那where4.is the variance and2is the standard deviation.

References

[1] Kotz, S., N. Balakrishnan, and N. L. Johnson.Continuous Multivariate Distributions: Volume 1: Models and Applications.第二辑。纽约:2000年John Wiley&Sons,Inc。

Extended Capabilities

在R2006A之前介绍