MATLAB Answers

Integrating multivariate Gaussian pdf in 3 dimensions and above

14 views (last 30 days)
Dilshad Raihan
Dilshad Raihan on 11 Sep 2014
Commented: ASKH on 22 Oct 2019
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.
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(<>) and got the following error message.
>> 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 Comment
ASKH on 22 Oct 2019
I am struggling with a similar problem. I only have a two-dimensional pdf, but still, I get the error message = [ 0 0];
par.sigma = [ 1, 0.2;
0.2, 1];
fun = @(lnla,lnlb) lnla .* mvnpdf([lnla lnlb],,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 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 =
>> d
d =

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!