Re: problems with Nmaximization
- To: mathgroup at smc.vnet.net
- Subject: [mg67833] Re: [mg67815] problems with Nmaximization
- From: Bruce Miller <brucem at wolfram.com>
- Date: Sun, 9 Jul 2006 04:51:18 -0400 (EDT)
- References: <200607080857.EAA20490@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Sat, Jul 08, 2006 at 04:57:02AM -0400, narsi wrote: > I am trying to use nmax to evaluate a function using Nmaximize. The > function is as follows. > > \!\(m[1] = 75\[IndentingNewLine] > m[2] = 36\[IndentingNewLine] > m[3] = 12\[IndentingNewLine] > m[4] = 4\[IndentingNewLine] > m[5] = 2\[IndentingNewLine] > m[6] = 0\[IndentingNewLine] > m[7] = 0\[IndentingNewLine] > m[8] = 0\[IndentingNewLine] > m[9] = 0\[IndentingNewLine] > n[1] = 571 - 75\[IndentingNewLine] > n[2] = 338 - 36\[IndentingNewLine] > n[3] = 173 - 12\[IndentingNewLine] > n[4] = 93 - 4\[IndentingNewLine] > n[5] = 41 - 2\[IndentingNewLine] > n[6] = 21\[IndentingNewLine] > n[7] = 10\[IndentingNewLine] > n[8] = 6\[IndentingNewLine] > n[9] = 4\[IndentingNewLine]\[IndentingNewLine] > NMaximize[{â??\+\(t = 1\)\%9\((m[ > t]*Log[\((\(h\ *p*\((1 - > p)\)\^\((t - 1)\)\)\/\(1 - h + h*\((1 - p)\)\^\((t - 1)\)\))\)] - > n[t]*Log[1 - \((\(h\ *p*\((1 - p)\)\^\((t - 1)\)\)\/\(1 - h + > h*\((1 - p)\)\^\((t - 1)\)\))\)])\), 1 â?¥ h â?¥ 0, 1 â?¥ p â?¥ 0}, > {h, p}]\) > > I cannot get this to converge. It gives me the following message > > \!\(ower::"infy" \(\(:\)\(\ \)\) " > Infinite expression \!\(1\/0.`\) encountered"\) > > > Can someone please help with this error in mathematica. I dont know > what the problem is. > > Thanks > > narsi This is an issue of Mathematics, not Mathematica. The domains of p and h inclued a singularity. In[1]:= $VersionNumber Out[1]= 5.2 In[2]:= m[1] = 75; m[2] = 36; m[3] = 12; m[4] = 4; m[5] = 2; m[6] = 0; m[7] = 0; m[8] = 0; m[9] = 0; n[1] = 571 - 75; n[2] = 338 - 36; n[3] = 173 - 12; n[4] = 93 - 4; n[5] = 41 - 2; n[6] = 21; n[7] = 10; n[8] = 6; n[9] = 4; In[20]:= NMaximize[{Sum[m[t]*Log[(h*p*(1 - p)^(t - 1))/ (1 - h + h*(1 - p)^(t - 1))] - n[t]*Log[1 - (h*p*(1 - p)^(t - 1))/( 1 - h + h*(1 - p)^(t - 1))], {t, 1, 9}], 1 >= h >= 0, 1 >= p >= 0}, {h, p}] 1 Power::infy: Infinite expression -- encountered. Moreâ?¦ 0. 1 Power::infy: Infinite expression -- encountered. Moreâ?¦ 0. 1 Power::infy: Infinite expression -- encountered. Moreâ?¦ 0. General::stop: Further output of Power::infy will be suppressed during this calculation. Moreâ?¦ Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. Moreâ?¦ Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. Moreâ?¦ Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. Moreâ?¦ General::stop: Further output of Infinity::indet will be suppressed during this calculation. Moreâ?¦ NMaximize::nnum: The function value Indeterminate is not a number at {h, p} = {1., 1.}. Moreâ?¦ Out[20]= {9708.75, {h -> 1., p -> 0.999817}} This is because the summand contains (1-p) terms in the denominator which can cause a singularity at p=1, which you said was in the allowed domain of p. The simpest way around this is to disallow p=1. (The singularity requires h=1, also.) In[21]:= m[t]*Log[(h*p*(1 - p)^(t - 1))/ (1 - h + h*(1 - p)^(t - 1))] - n[t]*Log[1 - (h*p*(1 - p)^(t - 1))/( 1 - h + h*(1 - p)^(t - 1))] Out[21]= -1 + t h (1 - p) p Log[-----------------------] m[t] - -1 + t 1 - h + h (1 - p) -1 + t h (1 - p) p Log[1 - -----------------------] n[t] -1 + t 1 - h + h (1 - p) This just restricts p. In[22]:= NMaximize[{Sum[m[t]*Log[(h*p*(1 - p)^(t - 1))/ (1 - h + h*(1 - p)^(t - 1))] - n[t]*Log[1 - (h*p*(1 - p)^(t - 1))/( 1 - h + h*(1 - p)^(t - 1))], {t, 1, 9}], 1 >= h >= 0, 0.999 >= p >= 0}, {h, p}] Out[22]= {7791.82, {h -> 1., p -> 0.999}} It may be that the expression is not quite the one you want, or there are other constraints. Bruce Miller Technical Support Wolfram Research, Inc. support at wolfram.com http://support.wolfram.com/
- References:
- problems with Nmaximization
- From: "narsi" <narasimhan.sowmyanarayanan@gmail.com>
- problems with Nmaximization