Integrating multivariate Gaussian pdf in 3 dimensions and above

조회 수: 8 (최근 30일)
Dilshad Raihan
Dilshad Raihan 2014년 9월 11일
댓글: ASKH 2019년 10월 22일
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
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 CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by