Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Problem with NMaximize
Replies: 11   Last Post: Jun 28, 2008 5:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jean-Marc Gulliet

Posts: 2,276
Registered: 6/12/05
Re: Problem with NMaximize
Posted: Jun 27, 2008 6:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Ramiro Barrantes-Reynolds wrote:

<snip>

> {res, data} =
> Reap[NMaximize[{logLikelihood[{{5, 5, 0, 0}, {3, 1, 0, 1}}, {33, 83,
> 11, 14}, S,
> a, {l1, l2, l3, l4}, {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
> t11, t12}], l1 > 0, l2 > 0, l3 > 0, l4 > 0, t1 > 0, t2 > 0,
> t3 > 0, t4 > 0, t5 > 0, t6 > 0, t7 > 0, t8 > 0, t9 > 0, t10 > 0,
> t11 > 0, t12 > 0,
> t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11 + t12 ==
> 1}, {a, l1, l2, l3, l4, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
> t11, t12},
> EvaluationMonitor :>
> Sow[{a, {l1, l2, l3, l4}, {t1, t2, t3, t4, t5, t6, t7, t8, t9,
> t10, t11, t12}}]]];


The code is not complete since you did not post the definition of the
function logLikelihood[...]

> NMaximize::nrnum: The function value 28.2245-6.28319 I is not a real \
> number at {a,l1,l2,l3,l4,t1,t10,t11,t12,t2,<<7>>} = \
> {1.,2.,2.,<<6>>,0.0799689,<<7>>}. >>


Nevertheless, by reading this above error message I bet that your
function is called with symbolic arguments (i.e. non-numeric arguments).
The following should help to correctly defined your function so it will
be called by NMaximize only when all its arguments are numeric values.

"How do I write a function which evaluates only when the argument is a
number?"

http://support.wolfram.com/mathematica/kernel/features/evalwhennumber.html

Regards,
-- Jean-Marc




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.