MathGroup Archive 2005

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

Search the Archive

Re: Problem behavior with FindMaximum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59723] Re: Problem behavior with FindMaximum
  • From: "James Gilmore" <james.gilmore at yale.edu>
  • Date: Fri, 19 Aug 2005 04:31:46 -0400 (EDT)
  • Organization: Yale University
  • References: <ddur1e$oc4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

No bug here. You are passing a variable not a number to myFunc2, using the 
second FindMax. Options --

1) Convert your function to numerical form and use an Interpolation object
myFunc1[a_, b_] := 1/((a - 16)^2 + 1) - (a - b)^2
myFunc2[a_] := FindMaximum[myFunc1[a, b], {b, 0}][[1]]
FindMaximum[myFunc2[x], {x, 14}]
Table[{x, myFunc2[x]}, {x, 1, 20, 0.017}];
myF2 = Interpolation[%, InterpolationOrder -> 2];
FindMaximum[myF2[x], {x, 15}]

2) Change your definition of the second maximization, to include both 
maximisations, to be compatible with FindMaximum constructs.

FindMaximum[myFunc1[a, b], {b, 0},{a,0}]

This is preferred because it is optimised, 1) is certainly not.
-- 
James Gilmore

Graduate Student
Department of Physics
Yale University
New Haven, CT 06520 USA

"James H. Steiger" <jsteiger at bellsouth.net> wrote in message 
news:ddur1e$oc4$1 at smc.vnet.net...
> Hello all:
>
> I wonder if you could give me some advice about behavior of FindMaximum[]
> that I cannot seem to decipher.
>
> There is a broad class of problems in statistics that involves finding the
> maximum
> of a function of several parameters, all but one (call it "a") of which 
> are
> *nuisance parameters*.
> The function is evaluated at any value of "a" by maximizing it w.r.t. all
> the nuisance parameters.
>
> A simple example (constructed just for Mathgroup -- the actual
> functions I work with are messier)  should make this clear.
>
>
> myFunc1[a_, b_] := 1/((a - 16)^2 + 1) - (a - b)^2
> myFunc2[a_] := FindMaximum[myFunc1[a, b], {b, 0}][[1]]
>
> FindMaximum returns a list, the first element of which is the maximized
> value of the function,
> the second of which is a replacement rule specifying the value of b at 
> which
> the maximum occurs.
>
> As you can quickly verify, myFunc2 is well behaved, and you can plot 
> myFunc2
> without incident.
>
> Plot[myFunc2[a],{a,14,18}] produces a nice plot with no error messages
>
> Here is where the problem arises. Suppose you want to use FindMaximum[] to
> obtain the maximum of myFunc2 which clearly occurs at
> a=16.
>
> If you input the command
>
> FindMaximum[myFunc2[x],{x,14}]
>
> you obtain a pair of error messages (can anyone tell me how to copy these 
> in
> Mathematica as text?)
>
> -----------------
>
> FindMaximum::nnum: The function value 1/((1+<<1>>)^2) - (0.+a)^2 is not a
> number at {b}={0.}
>
> FindMaximum::nnum: The function value 0.2 - (14. -b)^2 is not a number at
> {a}={14.}
>
> -----------------
>
> Is there some problem of "scope" of these variables that I am not aware 
> of?
> Or is there some bug in FindMaximum[]?
> Is there a fix?
>
> Thanks to all,
>
> Jim
>
>
> James H. Steiger, Professor and Director
> Quantitative Methods and Evaluation
> Dept. of Psychology and Human Development
> Vanderbilt University
> Peabody College #512
> Nashville, TN, 37203
>
> Phone: 615-322-7060
> email: james.h.steiger at vanderbilt.edu
> 



  • Prev by Date: Re: FindRoot for the determinant of a matrix with a varying size
  • Next by Date: Re: [long] Mathematica 5.1 and memory: any garbage collection?
  • Previous by thread: Re: Problem behavior with FindMaximum
  • Next by thread: Problem with Mathematica 5.2 on G5 Macintosh Systems