1. ## Trivariate normal distribution

Hi, I tried to compute an integral in Matlab, but it did not work. I would very much appreciate any help with this!

The function I am integrating is:

f = normpdf(x1, 4, 0.3) * normpdf(x2, 5.6, 0.8) * normpdf(x3, 3.8, 0.5)

The command I used:

int(int(int(f, x3, 0, 5-x1-x2), x2, 0, 5-x1), x1, 0, 5)

2. Originally Posted by Didi UMD
Hi, I tried to compute an integral in Matlab, but it did not work. I would very much appreciate any help with this!

The function I am integrating is:

f = normpdf(x1, 4, 0.3) * normpdf(x2, 5.6, 0.8) * normpdf(x3, 3.8, 0.5)

The command I used:

int(int(int(f, x3, 0, 5-x1-x2), x2, 0, 5-x1), x1, 0, 5)
1. What error messages are you getting?

2. Have you declared x1, x2, x3 to be symbolic variables

3. This almost certainly has no closed form solution, try doing it numerically.

CB

3. ## Thanks CaptainBlack

Thanks for taking time to help me with this CaptainBlack! As for the questions, yes I have declared x1 x2 and x3 to be symbolic variables (syms x1 x2 x3). Moreover, I am aware that there is no closed form solution for such integral and therefore I thought that Matlab would approximate it numerically itself. So, is there some other function in Matlab I should call in order to estimate the solution numerically? Many thanks!

As for the error function, it reports erf. Here is the report I am getting:

Warning: Explicit integral could not be found.
> In sym.int at 58

ans =

int(int(228359630832953580969325755111919221821239 45984/172635605422472869879069616780005304696582232237*e rf(19/5*2^(1/2))*2^(1/2)*pi^(1/2)*exp(-50/9*x1^2+400/9*x1-2041/18-25/32*x2^2+35/4*x2)-22835963083295358096932575511191922182123945984/172635605422472869879069616780005304696582232237*e rf(-6/5*2^(1/2)+2^(1/2)*x1+2^(1/2)*x2)*2^(1/2)*pi^(1/2)*exp(-50/9*x1^2+400/9*x1-2041/18-25/32*x2^2+35/4*x2),x2 = 0 .. 5-x1),x1 = 0 .. 5)

4. Originally Posted by Didi UMD
Thanks for taking time to help me with this CaptainBlack! As for the questions, yes I have declared x1 x2 and x3 to be symbolic variables (syms x1 x2 x3). Moreover, I am aware that there is no closed form solution for such integral and therefore I thought that Matlab would approximate it numerically itself. So, is there some other function in Matlab I should call in order to estimate the solution numerically? Many thanks!
Try:

Code:
eval(int(int(int(f,x3,0,5-x1-x2),x2,0,5-x1),x1,0,5))
CB

5. ## Thanks again

Originally Posted by CaptainBlack
Try:

Code:
eval(int(int(int(f,x3,0,5-x1-x2),x2,0,5-x1),x1,0,5))
CB
Thanks again CB! I tried it, but it did not work. Could it be that computation of a trivariate normal distribution is "too hard" for Matlab? Is there any other software or math modeling language that you think it might do better?

Thanks,
Didi

6. Originally Posted by Didi UMD
Thanks again CB! I tried it, but it did not work. Could it be that computation of a trivariate normal distribution is "too hard" for Matlab? Is there any other software or math modeling language that you think it might do better?

Thanks,
Didi
If you are interested in approximate values $\displaystyle 7.11 \times 10^{-13}$ with a standard error $\displaystyle \approx 0.03 \times 10^{-13}$ is what I get from Monte-Carlo integration over the region $\displaystyle x+y+x<5$ and $\displaystyle x>0, y>0, z>0$.

CB

7. ## Thanks

Originally Posted by CaptainBlack
If you are interested in approximate values $\displaystyle 1.185 \times 10^{-13}$ with a standard error $\displaystyle \approx 0.009 \times 10^{-13}$ is what I get from Monte-Carlo integration over the region $\displaystyle x+y+x<5$ and $\displaystyle x>0, y>0, z>0$.

CB
Many thanks, it is just what I needed! I would have one last question and I will stop bothering you about this problem. Can you please post me some reference on how you computed it? I am familiar with the idea of Monte-Carlo integration (had it in my probability and statistics course) but I don't know how to apply it in Matlab. I searched for it in Help, but did not find anything related.

Cheers,
Didi

8. Originally Posted by Didi UMD
Many thanks, it is just what I needed! I would have one last question and I will stop bothering you about this problem. Can you please post me some reference on how you computed it? I am familiar with the idea of Monte-Carlo integration (had it in my probability and statistics course) but I don't know how to apply it in Matlab. I searched for it in Help, but did not find anything related.

Cheers,
Didi
Note I have corrected the value of the integral since what is in your quote (I missed a factor of 6 out of the calculation )

CB

9. ## Thanks again

Originally Posted by CaptainBlack
Note I have corrected the value of the integral since what is in your quote (I missed a factor of 6 out of the calculation )

CB
Thanks. Would you please let me know which function you used in order to compute it? Was it in Matlab?

Thanks again!

10. Originally Posted by Didi UMD
Thanks. Would you please let me know which function you used in order to compute it? Was it in Matlab?

Thanks again!
This was done in Euler, which is a Matlab like system. There was no special function I just generated a large number of points uniformly distributed over the region of integration and found the average value of the function over the points. I then repeated the process a number of times to estimate the standard error in the integral.

(that is a paraphrase of the actual method but essentially it)

CB

11. ## Thx

Originally Posted by CaptainBlack
This was done in Euler, which is a Matlab like system. There was no special function I just generated a large number of points uniformly distributed over the region of integration and found the average value of the function over the points. I then repeated the process a number of times to estimate the standard error in the integral.

(that is a paraphrase of the actual method but essentially it)

CB
Thanks CB, you helped me a lot!

Cheers,
Didi