Re: Problem with NMaximize
- To: mathgroup at smc.vnet.net
- Subject: [mg90037] Re: Problem with NMaximize
- From: ramiro <ramiro.barrantes at uvm.edu>
- Date: Fri, 27 Jun 2008 06:14:51 -0400 (EDT)
- References: <g3vkvi$kio$1@smc.vnet.net> <4863CA88.5040100@gmail.com>
Thank you very much for your responses, Bobby and Jean-Marc. I did try changing the parametrization (thanks Bobby!) and I got an answer. However, let me try again with a hopefully more clear example, as I don't understand why this doesn't work, in particular, I don't understand why is it evaluating negative numbers if I am putting as a constraint that it shouldn't? Sample likelihood, In[196]:= logLikelihood1[t1_?NumberQ, t2_?NumberQ, t3_?NumberQ, t4_?NumberQ, t5_?NumberQ, t6_?NumberQ, t7_?NumberQ, t8_?NumberQ, t9_?NumberQ, t10_?NumberQ, t11_?NumberQ, t12_?NumberQ] := Log[0.00001712341312000713` t1 + 5.648647024829866`*^-6 t10 + 8.90597537441381`*^-6 t11 + 1.9727284288726167`*^-6 t12 + 4.102725237468317`*^-6 t2 + 3.7864902508468615`*^-6 t3 + 9.215772325326653`*^-7 t4 + 0.000057161484895917856` t5 + 0.000012892953334779516` t6 + 8.646320198720343`*^-6 t7 + 5.877910295858781`*^-6 t8 + 1.6837835562631724`*^-6 t9]; Another version (without the NumberQ)... In[197]:= logLikelihood2[t1_, t2_, t3_, t4_, t5_, t6_, t7_, t8_, t9_, t10_, t11_, t12_] := Log[0.00001712341312000713` t1 + 5.648647024829866`*^-6 t10 + 8.90597537441381`*^-6 t11 + 1.9727284288726167`*^-6 t12 + 4.102725237468317`*^-6 t2 + 3.7864902508468615`*^-6 t3 + 9.215772325326653`*^-7 t4 + 0.000057161484895917856` t5 + 0.000012892953334779516` t6 + 8.646320198720343`*^-6 t7 + 5.877910295858781`*^-6 t8 + 1.6837835562631724`*^-6 t9]; In[198]:= NMaximize[{logLikelihood1[t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12], 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 + t10 + t11 + t12 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 == 1}, {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12}] During evaluation of In[198]:= NMaximize::nrnum: The function value \ 15.7729-3.14159 I is not a real number at \ {t1,t10,t11,t12,t2,t3,t4,t5,t6,t7,<<2>>} = {-0.490249,<<9>>,<<2>>}. \ >> Out[198]= {-13.2945, {t1 -> 2.10942*10^-15, t10 -> -2.22045*10^-16, t11 -> -2.22045*10^-16, t12 -> -2.22045*10^-16, t2 -> -1.11022*10^-16, t3 -> -2.22045*10^-16, t4 -> -2.22045*10^-16, t5 -> -6.93889*10^-18, t6 -> -2.22045*10^-16, t7 -> -1.11022*10^-16, t8 -> -4.44089*10^-16, t9 -> 1.}} In[199]:= NMaximize[{logLikelihood2[t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12], 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}, {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12}] During evaluation of In[199]:= NMaximize::nrnum: The function value \ 15.7729-3.14159 I is not a real number at \ {t1,t10,t11,t12,t2,t3,t4,t5,t6,t7,<<2>>} = {-0.490249,<<9>>,<<2>>}. \ >> Out[199]= {-13.2945, {t1 -> 2.10942*10^-15, t10 -> -2.22045*10^-16, t11 -> -2.22045*10^-16, t12 -> -2.22045*10^-16, t2 -> -1.11022*10^-16, t3 -> -2.22045*10^-16, t4 -> -2.22045*10^-16, t5 -> -6.93889*10^-18, t6 -> -2.22045*10^-16, t7 -> -1.11022*10^-16, t8 -> -4.44089*10^-16, t9 -> 1.}}
- Follow-Ups:
- Re: Re: Problem with NMaximize
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Re: Problem with NMaximize