Re: Running a loop for Maximizing problem
- To: mathgroup at smc.vnet.net
- Subject: [mg75477] Re: Running a loop for Maximizing problem
- From: Daniel Huber <dh at metrohm.ch>
- Date: Wed, 2 May 2007 03:53:22 -0400 (EDT)
- References: <463878370200000B002AFE55@its-gw-inet57.its.rmit.edu.au>
Hi Shafiq, OLE has 3 not 2 variables: b1,b2 and p. Do you want a maximum relative to all 3 variables or only relative to b1 and b2 with p kept constant? It seems that the variables must fullfill some restrictions, otherwise OLE is not even real. Further, does OLE really have a global maximum or are you looking for a local maximum? Daniel Shafiq Ahmad wrote: > Hi > > I've a non linear equation (OLE) and need to solve it to get the Maximum > Likelihood values. To do so, I tried a loop that every time the value > of b1 and b2 changes ranging from 10 to 100 with step of 10 and get the > Maximized value for OLE. The idea behind is to find a contour or > surface with axis such as b1=X-axis, b2=Y-axis and OLE= Zaxis > > Is any one can suggest any idea? Below are the codes I tried > ============================ > > In[173]:= > n = 20 > x1 = {1.04, 1.06, 1.09, 1.05, 1.07, 1.06, 1.05, 1.1, 1.09, 1.05, 0.99, > 1.06, 1.05, 1.07, 1.11, 1.04, 1.03, 1.05, 1.06, 1.04} > x2 = {115.25, 115.91, 115.05, 116.21, 115.9, 115.55, 114.98, 115.25, > 116.15, 115.92, 115.75, 114.9, 116.01, 115.83, 115.29, 115.63, 115.47, > 115.58, 115.72, 115.4} > > pars = {b1, b2} > valsset = Table[{b1, b2}, {b1, 10, 100, 10}, {b2, 10, 100, 10}] > valsset = Flatten[valsset, 1] > rules = (MapThread[Rule, {pars, #1}] & ) /@ valsset > L/.rules > > In[176]:= > OLE = n*Log[p] + n*Log[p + 1] + n*Log[b1] + n*Log[b2] + (b1 - > 1)*Sum[Log[x1[[j]]], {j, 1, n}] + (b2 - 1)*Sum[Log[x2[[j]]], {j, 1, n}] > - > (p + 2)*Sum[Log[1 + x1[[j]]^b1 + x2[[j]]^b2], {j, 1, n}] > > In[177]:= > Eqn1 = D[OLE, b1] == 0 > Eqn2 = D[OLE, b2] == 0 > Eqn3 = D[OLE, p] == 0 > FindRoot[{Eqn1, Eqn2, Eqn3}, {b1, 10}, {b2, 10}, {p, 1}] > > ============================ > > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.ch> Internet:<http://www.metrohm.ch>