Results 1 to 11 of 11

Math Help - Trivariate normal distribution

  1. #1
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    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)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Didi UMD View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    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)
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Didi UMD View Post
    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
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    Thanks again

    Quote Originally Posted by CaptainBlack View Post
    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
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Didi UMD View Post
    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 7.11 \times 10^{-13} with a standard error \approx 0.03 \times 10^{-13} is what I get from Monte-Carlo integration over the region x+y+x<5 and x>0, y>0, z>0.

    CB
    Last edited by CaptainBlack; December 29th 2009 at 10:24 PM.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    Thanks

    Quote Originally Posted by CaptainBlack View Post
    If you are interested in approximate values 1.185 \times 10^{-13} with a standard error \approx 0.009 \times 10^{-13} is what I get from Monte-Carlo integration over the region x+y+x<5 and 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
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Didi UMD View Post
    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
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    Thanks again

    Quote Originally Posted by CaptainBlack View Post
    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!
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Didi UMD View Post
    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
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Dec 2009
    From
    Washington DC
    Posts
    7

    Thx

    Quote Originally Posted by CaptainBlack View Post
    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] Mixing a uniform distribution with a normal distribution
    Posted in the Advanced Statistics Forum
    Replies: 4
    Last Post: July 8th 2011, 08:27 AM
  2. normal distribution prior and posterior distribution proof
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: March 9th 2011, 06:12 PM
  3. Replies: 1
    Last Post: October 18th 2010, 01:41 PM
  4. Replies: 2
    Last Post: March 29th 2010, 02:05 PM
  5. Replies: 1
    Last Post: April 20th 2008, 06:35 PM

Search Tags


/mathhelpforum @mathhelpforum