Integrating multivariate Gaussian pdf in 3 dimensions and above
3 ビュー (過去 30 日間)
古いコメントを表示
I have been trying to integrate a multivariate Gaussian pdf in 3,4 and 6 dimensions for a certain problem. The full solution of the problem would involve integrating functions of the normal pdf so that merely computing the CDF wont do. The integration limits are constants. For 3 dimensions, I tried the following code.
mu1=zeros(3,1);
cov1=eye(3)
fun=@(x,y,z)mvnpdf([x,y,z],mu1',cov1)
integral3(@(x,y,z)fun(x,y,z),-1,1,-2,1,-1,1)
Error using mvnpdf (line 67)
X and MU must have the same number of columns.
And for 4D I used the answer provided at this link(<http://www.mathworks.com/matlabcentral/answers/77571-how-to-perform-4d-integral-in-matlab>) and got the following error message.
cov2=eye(4);
>> mu2=zeros(4,1);
>> Q = integral(@(x)integral3(@(y,z,w)mvnpdf([x,y,z,w],mu2',cov2),-2,3,-1,1,-3,1),-2,1,'ArrayValued',true);
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in @(y,z,w)mvnpdf([x,y,z,w],mu2',cov2)
I tried a similar nested approach using integral3 for 6D integral. But it gave an error too.
1 件のコメント
ASKH
2019 年 10 月 22 日
Hi,
I am struggling with a similar problem. I only have a two-dimensional pdf, but still, I get the error message
par.mu = [ 0 0];
par.sigma = [ 1, 0.2;
0.2, 1];
fun = @(lnla,lnlb) lnla .* mvnpdf([lnla lnlb],par.mu,par.sigma);
lnLm(1,1) = integral2(fun,-inf,inf,-inf,1);
Error using mvnpdf (line 67)
X and MU must have the same number of columns.
It seems like Matlab interprets my multi-dimensional function fun as a one-dimensional object, so that it does not accept par.mu and par.sigma to be 1-by-2 and 2-by-2 respectively.
Does anyone have any advice on how to proceed to be able to integrate?
>> [n,d] = size(fun);
>> n
n =
1
>> d
d =
1
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!