MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Integrate the Multivariate normal distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67468] Re: [mg67466] Re: [mg67451] Integrate the Multivariate normal distribution
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 27 Jun 2006 03:14:36 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

Needs["Statistics`MultinormalDistribution`"];

r={{1,1/5},{1/5,1}};

ndist=MultinormalDistribution[{0,0},r];

pdf=PDF[ndist,{x1,x2}]//Simplify;

Integrate[pdf,{x1,-Infinity,0},{x2,-Infinity,0}]

(Pi + 2*ArcCot[2*Sqrt[6]])/(4*Pi)

%//N

0.282047

CDF[ndist,{0,0}]

0.282047

Integrate[pdf,{x2,-Infinity,1}]

Erfc[(x1 - 5)/(4*Sqrt[3])]/(E^(x1^2/2)*(2*Sqrt[2*Pi]))

Integrate[pdf,{x2,-Infinity,1},{x1,-Infinity,Infinity}]

(1/2)*(1 + Erf[1/Sqrt[2]])

%//N

0.841345

NIntegrate[pdf,{x1,-Infinity,Infinity},{x2,-Infinity,1}]

0.841345

CDF[ndist,{Infinity,1}]

0.841345


Bob Hanlon

---- Miguel Lejeune <mlejeune at andrew.cmu.edu> wrote: 
> Thank you Bob.
> 
> I have one more question, also related to the bivariate normal distribution.
> 
> I would like to compute (numerically) the following integrale (PDF is the 
> probability density function of the bivariate normal distribution):
> 
> Integrale of  [PDF[ndist, {x1, x2}] with respect to x2 (dx2) and the 
> integration bounds are -Infinity and 1.
> with
> ndist = MultinormalDistribution[{0, 0}, r];
> r = {{1, 0.2}, {0.2, 1}};
> 
> 
> Could you indicate me how I should do?
> 
> Many thanks,
> Miguel
> 
> 
> ----- Original Message ----- 
> From: "Bob Hanlon" <hanlonr at cox.net>
To: mathgroup at smc.vnet.net
> Subject: [mg67468] [mg67466] Re: [mg67451] Integrate the Multivariate normal distribution
> 
> 
> > You need to load the package.
> >
> > Off[General::spell1];
> >
> > Needs["Statistics`MultinormalDistribution`"];
> >
> > r={{1,0.2},{0.2,1}};
> >
> > ndist=MultinormalDistribution[{0,0},r];
> >
> > pdf=PDF[ndist,{x1,x2}]
> >
> > 0.16243683359034922*
> >  E^((1/2)*((-x1)*(1.0416666666666667*x1 -
> >       0.20833333333333337*x2) -
> >     x2*(1.0416666666666667*x2 - 0.20833333333333337*x1)))
> >
> > ContourPlot[pdf,{x1,-2,2},{x2,-2,2}];
> >
> > NIntegrate[CDF[ndist,{x1,x2}],
> >  {x1,-Infinity,0},{x2,-Infinity,0}]
> >
> > 0.212349
> >
> >
> > Bob Hanlon
> >
> > ---- Miguel Lejeune <mlejeune at andrew.cmu.edu> wrote:
> >>   Hello,
> >>
> >>   I am using the MultiNormal function to compute the probability density
> >> function (pdf_ and cumulative probability distribution (cdf) of a
> >> bivraite normally distributed variable.
> >>
> >>   I have two questions.
> >>
> >>   1) I followed the help file to get familiar with that function.
> >>   But although I repeat what is indicated, I do not obtain the same
> >> output. Could you please indicate me?
> >>   Example:
> >>
> >>   In:  Statistics`MultinormalDistribution
> >>   In: (r = {{1, 0.2}, {0.2, 1}};
> >>   ndist = MultinormalDistribution[{0, 0}, r])
> >>
> >>   I obtain as output:
> >>   Out: MultinormalDistribution [ {{0, 0}, {1, 0.2}, {1,0.2, 1}}]
> >>   which is fine.
> >>
> >>   However, when I type:
> >>
> >>   In:  pdf = PDF[ndist, {x1, x2}]
> >>
> >>   The only output I obtain is:
> >>   MultinormalDistribution[{0, 0}, {{1, 0.2}, {1, 0, 2}}]
> >>
> >>   while in the help file it is indicated that I should obtain an
> >> algebraic expression.
> >>
> >>   Why is it??
> >>
> >>
> >>   2) My second question. I would like to proceed to the numerical
> >> integration of the CDF of the bivariate normal distribution. I enter:
> >>
> >>   In:   NIntegrate[CDF[ndist, {x1, x2}], {x1, -Infinity, 0}, 
> >> {x2,-Infinity, 0}]
> >>
> >>   I systematically obtain the following error message:
> >>
> >>   "NIntegrate::inum: Integrand CDF[MultinormalDistribution[{0, 0}, 
> >> {{1,0.5}, \
> >>   {1, 0, 5}}], {x1, x2}] is not numerical at {x1, x2} = {-1., -1.}
> >>   "
> >>   I do not understand why it is saying that the expression  is not
> >> numerical at {-1,1}. Could anybody help?
> >>
> >>
> >>
> >>   Many thanks,
> >>
> >>
> >>
> >>   Miguel


  • Prev by Date: Re: Quaternion problem-> visualization
  • Next by Date: Re: Points sampled by NIntegrate
  • Previous by thread: Re: Integrate the Multivariate normal distribution
  • Next by thread: Re: Integrate the Multivariate normal distribution