Pieter
Pieter

Reputation: 13

Mathematica: FindArgMax does not return a global maximum

I have a fairly highly oscillating function, and I need to find the ArgMax in the interval (-Pi,Pi).

When I Plot the function it is clear that FindArgMax picks the wrong maximum. I have tried adjusting AccuracyGoal and PrecisionGoal, and the various available Methods, but this does not seem to have the required effect.

w[SNR_] := 
 RandomVariate[NormalDistribution[0, 0.5*Sqrt[2]*10^(-SNR/20)], 16] + 
 I RandomVariate[NormalDistribution[0, 0.5*Sqrt[2]*10^(-SNR/20)], 16]

G[\[Omega]_] := Re[Sum[(Exp[1.2556 I (m - 1)] + noise[[m]]) Exp[-I \[Omega] (m - 1)], {m, 1, 16}]/16]

noise = w[-20];
estimate = FindArgMax[G[\[Omega]], \[Omega], Method -> "QuasiNewton", 
AccuracyGoal -> 30, PrecisionGoal -> 30][[1]];
Plot[G[x], {x, -Pi, Pi}, Epilog -> Line[{{estimate, -100}, {estimate, 100}}], PlotRange -> All, Frame -> True, Axes -> None, FrameTicks -> {{-Pi, -Pi/2, 0, Pi/2, Pi}, Automatic, {}, {}},PlotRangePadding -> {0, 0.05}]
Print[estimate]

Is there a way to find the global maximum?

Upvotes: 1

Views: 216

Answers (1)

Chris Degnen
Chris Degnen

Reputation: 8655

You need to approximate the start point or the maximisation will be too localised.

x0 = Sort[Table[{G[x], x}, {x, -Pi, Pi, 0.01}]][[-1, 2]];

estimate = Quiet@
   FindArgMax[{G[\[Omega]], -Pi <= \[Omega] <= Pi}, {\[Omega], x0}][[1]];

Plot[G[x], {x, -Pi, Pi},
 Epilog -> Line[{{estimate, -100}, {estimate, 100}}],
 PlotRange -> Full, Frame -> True, Axes -> None,
 FrameTicks -> {{Automatic, Automatic},
   {{-Pi, -Pi/2, 0, Pi/2, Pi}, None}},
 PlotRangePadding -> {0, 0.05}]
Print[estimate]

enter image description here

Upvotes: 1

Related Questions