2
$\begingroup$

Why is FindMinimum not giving me a result?

gau[x_, v_] := Exp[-(x^2)/(2*v)]/Sqrt[2*Pi*v];
mu = {-3, -2, -1, 7, 8};
n = Length[mu];
f[x_, v_] := Sum[gau[x - mu[[k]], v[[k]]], {k, 1, n}]/n;
penalty[q_?ListQ] := NIntegrate[f[x, Exp[q]]*Log[f[x, Exp[q]]]^2, {x, -Infinity, Infinity}] - NIntegrate[f[x, Exp[q]]*Log[f[x, Exp[q]]], {x, -Infinity, Infinity}]^2;
Table[penalty[RandomReal[.05, n]], {i, 1, 10}]
FindMinimum[penalty[q], {q, {0, 0, 0, 0, 0}}];

(* {0.471693, 0.473139, 0.471163, 0.472572, 0.471434, 0.472167, 0.473303, 0.467417, 0.472596, 0.47062}

FindMinimum::lstol: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances *)

The random sample results show that the penalty[] function can be decreased further, but FindMinimum doesn't even seem to be trying.

| improve this question | | | | |
$\endgroup$
4
$\begingroup$

Method -> "PrincipalAxis" gives a result:

{0.236921, {q -> {-2.27053, -1.95057, -2.27053, -2.30068, -2.30068}}}

According to the documentation

Direct search methods which do not require derivatives can be helpful in these cases

This also means NMinimize might be a good option.

| improve this answer | | | | |
$\endgroup$
  • 4
    $\begingroup$ Sometimes I think there should be Method->TryThemAll ツ $\endgroup$ – John Doty Jul 11 '16 at 2:24
  • 1
    $\begingroup$ @JohnDoty Either that or error messages that convey some useful information. $\endgroup$ – Jerry Guern Jul 11 '16 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.