How can I do bivariate numerical integration in Matlab for computing joint probabilities?

2 views (last 30 days)
Hi all, I have to compute the probabilities listed below for each row i of the matrices b and c. I assume that (u_1,u_2) are distributed as a bi-variate normal with mean mu and var-cov matrix sigma. Could you help me please?
b= unidrnd(10,100,2);
c= unidrnd(10,100,2);
sigma=[1 0.3;0.3 1];
mu=[0 0];
(1) Pr(u_1<-b(i,1); u_2<-b(i,2))
(2) Pr(u_1>=-c(i,1); u_2>=-c(i,2))
(3) Pr(u_1>-b(i,1); u_2<-b(i,2))
(4) Pr(u_1>-c(i,1);-b(:,2)<=u_2<=-c(i,2))
(5) Pr(u_1>-b(i,1); u_2<-c(i,2))
(6) Pr(u_1<-c(i,1); u_2> -c(i,2))
(7) Pr(u_1<-b(i,1);-b(:,2)<=u_2<=-c(i,2)
(8) Pr(u_1<-c(i,1); u_2>-b(i,2))

Accepted Answer

Roger Stafford
Roger Stafford on 9 Feb 2014
Edited: Roger Stafford on 9 Feb 2014
These can all be expressed in terms of the 'mvncdf' function. For (1) it would be:
P1 = mvncdf(-b,mu,sigma);
For (4) it would be: (I assume you meant "Pr(u_1>-c(i,1);-b(i,2)<=u_2<=-c(i,2))" rather than "Pr(u_1>-c(i,1);-b(:,2)<=u_2<=-c(i,2))" .)
P4 = mvncdf([-c(:,1),-b(:,2)],[repmat(inf,size(b,1),1),-c(:,2)],mu,sigma);
This latter uses the "rectangle" form of the 'mvncdf' call.
I think you should be able to work out the remaining cases for yourself using the concepts demonstrated here.
  3 Comments
Roger Stafford
Roger Stafford on 9 Feb 2014
I agree with your method for P21. However, I see no reason why you should expect that sum(P21-P22) to be almost zero. P22 includes all the cases where u_1>-c(i,1) OR u_2>-c(i,2) which will in general be a lot larger than P21 which contain those where u_1>-c(i,1) AND u_2>-c(i,2). What I am saying is that P21 contains a rectangle, whereas P22 contains everything outside the diagonally opposite rectangle and is therefore much larger. You have received a sizable negative value for sum(P21-P22). Am I right?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!