Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Problem with Integration/HoldPattern (?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85618] Problem with Integration/HoldPattern (?)
  • From: Steven Wronski <s___wronski at hotmail.com>
  • Date: Fri, 15 Feb 2008 06:50:54 -0500 (EST)

Hello,


I am trying to do a number of integrations where the integrand depends on numeric parameters ('data') that appear in arrays and vectors and so on.

If I can express the integrand in terms of a Mathematica 'known' CDF from the Statistics packages, then it is easy to pass through the parameters and get the numeric results desired.


However, for a symbolic integrand represented with Integrate, Mathematica wants to evaluate the integral before all of the data becomes available and so the machine hangs for a long period of time. I was able to suppress the evaluation using Hold and HoldPattern, but when this is done, I cannot pass the data through to update the integrand's parameters.


Clearly, if CDF can do what is needed, then this should be doable more generally but what CDF is doing is beyond me.


In the code below, the first part is written in terms of CDF and the second with identical integrand in terms of Integrate.


I searched the archive for a solution but it was not popping out at me.


Thanks for anyone's thoughts,
Steve

<< Statistics`MultinormalDistribution`
d = {{0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {1, 0, 0}, {1, 0, 0}};
z11 = {{0}, {-10}, {-2}, {5}, {1}};
z12 = {{7}, {1}, {6}, {7}, {11}};
z21 = {{0}, {11}, {2}, {-5}, {-1}};
z22 = {{8}, {12}, {8}, {2}, {10}};
(* Here CDF Is Used *)
f = CDF[MultinormalDistribution[{\[Mu]1, \[Mu]2},
{{1, \[Rho]}, {\[Rho], 1}}], {lim1, lim2}];
(* Remaining Material is Common to Both Approaches *)
Clear[i]
f1 = f /. {\[Mu]1 -> \[Mu]11\_i, \[Mu]2 -> \[Mu]12\_i};
f2 = f /. {\[Mu]1 -> \[Mu]21\_i, \[Mu]2 -> \[Mu]22\_i};
f3 = 1 - f1 - f2;
k=Log[f1^( d[[1,1]] + d[[2,1]] + d[[3,1]] + d[[4,1]] + d[[5,1]])*
f2^( d[[1,2]] + d[[2,2]] + d[[3,2]] + d[[4,2]] + d[[5,2]])*
f3^( d[[1,3]] + d[[2,3]] + d[[3,3]] + d[[4,3]] + d[[5,3]])]
dk = k /. {\[Mu]11\_i_ :> \[Alpha]*z11[[i]], \[Mu]12\_i_ :> \[Alpha]*
z12[[i]], \[Mu]21\_i_ :> \[Alpha]*z21[[i]], \ \[Mu]22\_i_ :> \[Alpha]*z22[[i]]};
dk /. {\[Alpha] -> -.1, \[Rho] -> .5, lim1 -> 0, lim2 -> 0}
(* Answer is -2.89153 *)

(* 2nd way using Integrate *)
f = Integrate[PDF[MultinormalDistribution[{\[Mu]1, \[Mu]2},
{{1, \[Rho]}, {\[Rho], 1}}],{x1, x2}], {x1, -\[Infinity], lim1}, {x2, -\[Infinity], lim2}] // HoldPattern
(* Remaining Material is Common to Both Approaches *)
Clear[i]
f1 = f /. {\[Mu]1 -> \[Mu]11\_i, \[Mu]2 -> \[Mu]12\_i};
f2 = f /. {\[Mu]1 -> \[Mu]21\_i, \[Mu]2 -> \[Mu]22\_i};
f3 = 1 - f1 - f2;
k=Log[f1^( d[[1,1]] + d[[2,1]] + d[[3,1]] + d[[4,1]] + d[[5,1]])*
f2^( d[[1,2]] + d[[2,2]] + d[[3,2]] + d[[4,2]] + d[[5,2]])*
f3^( d[[1,3]] + d[[2,3]] + d[[3,3]] + d[[4,3]] + d[[5,3]])]
dk = k /. {\[Mu]11\_i_ :> \[Alpha]*z11[[i]], \[Mu]12\_i_ :> \[Alpha]*
z12[[i]], \[Mu]21\_i_ :> \[Alpha]*z21[[i]], \ \[Mu]22\_i_ :> \[Alpha]*z22[[i]]};
dk /. {\[Alpha] -> -.1, \[Rho] -> .5, lim1 -> 0, lim2 -> 0}
(* Pattern matching is wrong. Does not evaluate properly. *)
_________________________________________________________________


  • Prev by Date: Archimedes' Spiral
  • Next by Date: Re: "Assuming"
  • Previous by thread: Re: Archimedes' Spiral
  • Next by thread: Default font