Re: Finding unknown parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg75166] Re: [mg75154] Finding unknown parameters
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Thu, 19 Apr 2007 04:30:30 -0400 (EDT)
- References: <200704180911.FAA08709@smc.vnet.net>
I don't know if this will help you, but I fed the solution of each iteration as the starting point for the successive iterations. (MMA 5.2 Kernel) In[1]:= x1:={1.3,1.33,1.28,1.25,1.29,1.32,1.38,1.24,1.26,1.24,1.25,1.3,1.27,1.3,1.32, 1.31,1.3,1.26,1.28,1.31,1.33,1.29,1.3,1.32,1.26,1.3,1.32,1.35,1.32,1.29} (MMA 5.2 Kernel) In[2]:= x2:={1.25,1.32,1.25,1.3,1.38,1.32,1.25,1.29,1.32,1.35,1.29,1.33,1.32,1.26,1.3, 1.25,1.25,1.29,1.31,1.31,1.27,1.26,1.29,1.31,1.28,1.33,1.27,1.26,1.29, 1.32} (MMA 5.2 Kernel) In[3]:= LMN[r1_,r2_,b1_,b2_,p_]= Module[{n=Length[x1]}, n*Log[p]+n*Log[p+1]+n*Log[b1]+n*Log[r1]+n*Log[b2]+ n*Log[r2]+(b1-1)*Sum[Log[x1[[j]]],{j,1,n}]+(b2-1)* Sum[Log[x2[[j]]],{j,1,n}]-(p+2)* Sum[Log[1+r1*x1[[j]]^b1+r2*x2[[j]]^b2],{j,1,n}]]; (MMA 5.2 Kernel) In[4]:= rr:=z_Complex\[Rule]{Re[z],Im[z]} (MMA 5.2 Kernel) In[5]:= eqns=Thread[D[LMN[r1,r2,b1,b2,p],{{b1,b2,p}}]\[Equal]0]; (MMA 5.2 Kernel) In[6]:= rMatrix=Table[{r1,r2},{r2,0.001,1,0.15},{r1,0.001,1,0.15}]; (MMA 5.2 Kernel) In[7]:= (*make each input domain point close to its neighbors*) rList=Flatten[MapIndexed[If[EvenQ[#2[[1]]],Reverse@#1,#1]&,rMatrix],1]; (MMA 5.2 Kernel) In[8]:= f=Block[{r1=#2[[1]],r2=#2[[2]],FindRoot},FindRoot[eqns,List@@@#1]]& (MMA 5.2 Kernel) In[9]:= ansList=Rest@FoldList[f,{b1\[Rule]20,b2\[Rule]20,p\[Rule]2},rList]; (MMA 5.2 Kernel) In[10]:= MapThread[Join[Thread[{r1,r2}\[Rule]#1],#2]&,{rList,ansList}] On 4/18/07, Shafiq Ahmad <shafiq.ahmad at rmit.edu.au> wrote: > Hi, > > Below are the codes to solve the non-linear equations that I could > furnished with help of Mr Jeans-Marc. After running the codes, I got > this error message (FindRoot::cvmit: "Failed to converge to the > requested accuracy or precision \within 100 iterations) when run some > real data of sample size 30. I did try to increase # of interations but > could not get success. Any one has any clue? > > ==================================== > > In[115]:= > LMN[r1_, r2_, b1_, b2_, p_] := Module[{n = Length[x1]}, n*Log[p] + > n*Log[p + 1] + n*Log[b1] + n*Log[r1] + n*Log[b2] + n*Log[r2] + > (b1 - 1)*Sum[Log[x1[[j]]], {j, 1, n}] + (b2 - 1)*Sum[Log[x2[[j]]], > {j, 1, n}] - (p + 2)*Sum[Log[1 + r1*x1[[j]]^b1 + r2*x2[[j]]^b2], {j, 1, > n}]] > x1 = {1.3, 1.33, 1.28, 1.25, 1.29, 1.32, 1.38, 1.24, 1.26, 1.24, 1.25, > 1.3, 1.27, 1.3, 1.32, 1.31, 1.3, 1.26, 1.28, 1.31, 1.33, 1.29, 1.3, > 1.32, 1.26, 1.3, 1.32, > 1.35, 1.32, 1.29} > x2 = {1.25, 1.32, 1.25, 1.3, 1.38, 1.32, 1.25, 1.29, 1.32, 1.35, 1.29, > 1.33, 1.32, 1.26, 1.3, 1.25, 1.25, 1.29, 1.31, 1.31, 1.27, 1.26, 1.29, > 1.31, 1.28, 1.33, 1.27, > 1.26, 1.29, 1.32} > rr = z_Complex -> {Re[z], Im[z]} > sols = Table[Block[{b1, b2, p, Eqn1, Eqn2, Eqn3}, Eqn1 = D[LMN[r1, r2, > b1, b2, p], b1] == 0; Eqn2 = D[LMN[r1, r2, b1, b2, p], b2] == 0; > Eqn3 = D[LMN[r1, r2, b1, b2, p], p] == 0; Join[{a -> r1, b -> > r2}, FindRoot[{Eqn1, Eqn2, Eqn3}, {b1, 10}, {b2, 10}, {p, 10}]]], {r1, > 0.001, 1, 0.15}, > {r2, 0.001, 1, 0.15}] /. a -> r1 /. b -> r2 > pts = LMN[r1, r2, b1, b2, p] /. sols > > In[121]:= > % /. rr > > ======================================= > > Regards > Shafiq > > > -- http://chris.chiasson.name/
- References:
- Finding unknown parameters
- From: "Shafiq Ahmad" <shafiq.ahmad@rmit.edu.au>
- Finding unknown parameters