Re: FindMinimum on a potentially Complex-valued function
- To: mathgroup at smc.vnet.net
- Subject: [mg8783] Re: FindMinimum on a potentially Complex-valued function
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Thu, 25 Sep 1997 12:26:17 -0400
- Organization: University of Western Australia
- Sender: owner-wri-mathgroup at wolfram.com
Luci Ellis wrote: > I have recently written a function that involves minimizing a > log-likelihood function. The function to be minimised is the log of an ugly > high-order polynomial in three variables. > > It works as expected for some data, but for other data sets, the > FindMinimum function ends up going to parameters that give complex-number > values of the objective function, and I get an error. (This also happens in > Gauss so it's not just a Mathematica problem). > > Is there some way of telling the FindMinimum function that if it hits > parameter values that give complex-valued results, it should move to some > other initial guesses for the FindMinimum and try again? FindMinumum has a 4 parameter calling-sequence, FindMinimum[f,{x,xstart,xmin,xmax}] which stops searching if x gets outside the range {xmin, xmax}. > eg, something like: If[FindMinimum[expr,{a,a0},{b,b0}]==Message[whatever > the name of the message that comes up > is],FindMinimum[expr,{a,a0+1},{b,b0+1}],FindMinimum[expr,{a,a0},{b,b0}]] > > And presumably put it in a While Loop, to keep progressively trying > starting values until it stops falling off the real line. Can you not modify expr so that it includes a Throw and use an enclosing Catch? See section 2.5.9 of the Mathematica book. Cheers, Paul ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul at physics.uwa.edu.au AUSTRALIA http://www.pd.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________