MathGroup Archive 1999

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

Search the Archive

using FindMinimum to minimize a function involving NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15483] using FindMinimum to minimize a function involving NIntegrate
  • From: "Albert Maydeu-Olivares" <amaydeu at nil.fut.es>
  • Date: Mon, 18 Jan 1999 04:22:25 -0500
  • Organization: University of Barcelona
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, everyone

I can't get FindMinimum to work when the function to be minimized
involves numerical integrals.
Any suggestions would be most welcome.

I enclose a typical example: I'm trying to minimize 	e .e where e =
	{data1-definite integral of a univariate normal distribution,
		data2- definite integral of a univariate normal distribution,
		data3- definite integral of a bivariatye normal distribution} using
Newton's method. 

Below is the code. The gradient is correct.

In[1]:=
dens[x_]=1/(E^(x^2/2)*Sqrt[2*Pi]);
p[h_]:=Module[{x},NIntegrate[dens[x],{x,h,Infinity}]] dens2[h_,k_,x_]= 
1/(2*E^((h^2 + k^2 - 2*h*k*x)/(2*(1 - x^2)))*Pi*Sqrt[1 - x^2]);
pp[h_,k_,r_]:=  Module[{x},
    NIntegrate[dens2[h,k,x],{x,0,r},PrecisionGoal->10]+p[h] p[k]]

In[3]:=
nvars=2;ncorr=1;
prop={.828,.628,.567};
t={t1,t2};
r={l1 *l2};
gradient={{-dens[t1],0,0,0},
	{0,-dens[t2],0,0},
	{dens[t1]*(-1 + Erf[(-(l1*l2*t1) + t2)/Sqrt[2 - 2*l1^2*l2^2]])/2,
         dens[t2]* (-1 + Erf[(t1 - l1*l2*t2)/Sqrt[2 - 2*l1^2*l2^2]])/2,
         dens2[t1,t2,l1*l2]*l2,	      dens2[t1,t2,l1*l2]*l1}};

In[4]:=
e := prop-{p[t[[1]]],p[t[[2]]],pp[t[[2]],t[[1]],r[[1]]]} ; FindMinimum[e
. e, {t1,-.95},{t2,-.4},{l1,.5},{l2,.6},
		Gradient->gradient, Method->Newton]

Out[4]=												
"Could not symbolically find the gradient of (e . e)
 Try giving two starting values for each variable."


I believe the error message given by FindMinimum is misleading.

Trying to figure out what's going on, I specify the problem using
Integrate and then 
numerically evaluating the integrals inside FindMinimum. It did not work
either. 
It just sit there.


In[11]:=
p2[h_]:=Integrate[dens[x],{x,h,Infinity}]
pp2[h_,k_,r_]:=Integrate[dens2[h,k,x],{x,0,r}]+p[h] p[k]

e2 := prop-{p2[t[[1]]],p2[t[[2]]],pp2[t[[2]],t[[1]],r[[1]]]} ;
FindMinimum[N[e2 . e2], {t1,-.95},{t2,-.4},{l1,.5},{l2,.6},


-- 

Albert Maydeu-Olivares			Tel. +34 3 4021079 ext. 3099 Faculty of
Psychology 			Fax. +34 3 4021362 University of Barcelona			E-Mail:
amaydeu at tinet.fut.es Passeig de la Vall d'Hebron, 171.  
08035 - Barcelona (Spain)



  • Prev by Date: Re: getting the name of a symbol
  • Next by Date: Re: Can this ODE be solved?
  • Previous by thread: Re: Getting rid of annoying zeroes in algebraic expressions
  • Next by thread: Re: using FindMinimum to minimize a function involving NIntegrate