Message Boards Message Boards

Finding critical points with NMaximize[] and Solve[] yielding different results query

Posted 1 month ago

I have two codes which carry out the same task, that is finding the maxima of a function. The function I am considering is a log-likelihood function. Since I am modelling a quantum process, I am using a random number generator to generate to measurement outcomes {m1,m1,m2} which then defines the log-likelihood function. The codes follow identical mathematical approaches, but In Code 1 I use the Mathematica built-in function NMaximize[] to find the critical points (which maximize the function) directly from the log-likelihood function, and in Code 2 I first take the derivative of the function and analytically solve for the points which yield the a zero derivative using the built-in Mathematica Solve[] function. I would expect these two approaches to yield identical results (or very similar results) for large iteration counts. But Code 1 does not converge to the expected value of 1.5, but instead maintains a negative bias by converging to about 1.475 (regardless of the number of trials). Code 2 converges to 1.5 as expected. Could anyone advise on the cause of the discrepancy. Many thanks for any assistance.

Note: I have tried setting different Methods in the NMaximum function but still get a negative bias. There also does not seem to be an appreciable difference when considering the built-in Maximum function as opposed to NMaximum, one still gets a negative bias.

POSTED BY: Byron Alexander
2 Replies

It is not clear to me why this optimization is expected to recover phi. The discrepancy in your results is actually user error: in going from the solution of this

Solve[D[llog[\[Phi]], \[Phi]] == 0, \[Phi]]

to this

f2[{m0_, m1_, m2_}] := 2 ArcTan[Sqrt[m1 + 2 m2]/Sqrt[2 m0 + m1]]

you changed 4s to 2s. This is equivalent to redefining

L[\[Phi]_, m0_, m1_, m2_] := (Cos[\[Phi]/2])^(2 m0)*(Sin[\[Phi]]/2)^
   m1*(Sin[\[Phi]/2])^(2 m2) 

Note the first and third exponents have factors of 2 rather than 4. With this change, \[Phi] /. NMaximize[{d[[i]], 0 <= \[Phi] <= Pi}, \[Phi]][[2]] will average pretty close to 1.5. (I still don't know why that would recover the 1.5, but will take on faith that it can do that. Must be a square root is useful somehow.)

POSTED BY: Daniel Lichtblau

Wow, I checked but clearly overlooked that particular treachery. You are a scholar, many thanks.

POSTED BY: Byron Alexander
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract