Ah hah. That looks much better to me. Thanks Alec. Gonna have a little play around with this now. :D
Joal Heagney On Mar 15, 10:35 am, Alec Mihailovs <alec.mihail...@gmail.com> wrote: > On Mar 12, 4:22 am, Joal Heagney <joalheag...@gmail.com> wrote: > > > > > Hi guys and gals, > > Currently I'm attempting to fit the following data to the general > > logistic model: > > > [(0,0),(1,0),(2,13),(3,28),(4,48),(5,89),(6,107),(7,168),(8,188),(9,209)] > > > The form of the logistic curve I am using is: > > > K/(1 + a*exp(r * (t - t0)))^(1/v) > > > with K,a,r,t0 and v being parameters, t the dependent variable. > > > Attempting to use find_fit, I get values of: > > [K == 84.999999972210745, a == 126.84970317061706, r == > > -183.75725583987102, t0 == -124.8433024602822, v == 105.35677984548882] > > > This is obviously wrong as K is nowhere near the right-hand asymptote in > > the data. Using a more bare-bones approach based on fmin, I get more > > realistic results of: > > [249.143779989,11.657027477,-0.535852892673,-0.0364250104883,0.52301206184] > > The K is approximately the average value of the data and the resulting > function is practically a constant K. > > Both Mathematica's function FindFit and Maple's function Statistics:- > Fit produce similar results with K close to 85 and different other > parameter values, buth also with the result being very close to a > constant function. > > The problem seems to be in the bad initial guess. > > A better initial guess produce rather nice looking answer in Sage, > > Using data and model(t) from the YannLC reply, > > data = [(0,0),(1,0),(2,13),(3,28),(4,48),(5,89),(6,107),(7,168), > (8,188),(9,209)] > > var('K,a,r,t,t0,v') > > model(t) = K/(1 + a*exp(r * (t - t0)))^(1/v) > > s=find_fit(data, > model,initial_guess=[200,10,0,1,1],parameters=[K,a,r,t0,v],solution_dict=True); > s > > {t0: 1.9182136806459771, K: 249.14668753230089, a: 4.0889718235600832, > r: -0.53583047134875161, v: 0.52295328451032852} > > plot([scatter_plot(data), plot(model(t).subs(s),(0,9))]) > > Alec Mihailovs -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe from this group, send email to sage-devel+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.