Re: Exponential fit question.
- To: mathgroup at smc.vnet.net
- Subject: [mg28025] Re: [mg27986] Exponential fit question.
- From: Chris Johnson <cjohnson at shell.faradic.net>
- Date: Wed, 28 Mar 2001 02:40:57 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
After a few minutes more looking, I don't think your Excel coefficients are better than Mathematica. This solution appears optimal to me. Chris On Tue, 27 Mar 2001, Chris Johnson wrote: > Joe, > > The Fit function only looks for Linear combinations of the functions > provided. You are looking for a non-linear solution which you can get by > loading the package Statistics`NonlinearFit`. > > After loading the package, it seems the solution is very unstable, so > mathematica still needs a nudge to push it in the right direction. Here > is what I found... > > In[93]:= > data = {{50, 22}, {64, 62}, {78, 122}, {93, 269}, > {107, 414}, {122, 507}, {136, 597}}; > > And just to see what we are working with... > p1 = ListPlot[data] > > First, I wanted to confirm your results... > > In[94]:= > fitcurve = Fit[data, Exp[x], x] > > Out[94]= > 5.151397928273716*^-57*E^x > > Which doesn't quite match what Mathematica gave you, but close enough. > And a plot of this relative to your data show it is not a reasonable fit. > > Next I load the NonlinearFit package and use that function... > > Needs["Statistics`NonlinearFit`"] > > In[95]:= > g2 = NonlinearFit[data, a1*E^(a2*x), x, {a1, a2}] > > Out[95]= > 4.930380657631324*^-32*E^(1.*x) > > This is no good, it assumes the x coeff. to be 1, and a plot of g2 is just > as bad as the first attempt using Fit. The next step was to give > Mathematica a nudge in the expected direction by this trick: > > In[96]:= > g3 = NonlinearFit[data, a1*E^(0.001*a2*x), x, {a1, a2}] > > Out[96]= > 26.60851641163635*E^(0.02349567063425155*x) > > A plot of g3 relative to the p1 plot shows a pretty close fit. > > Still, the parameters you have found with Excel do get closer on a Least > Squares basis. I hope someone else can help more, but I thought this > might be a good start. > > Chris > > > On Tue, 27 Mar 2001, joe wrote: > > > hello. > > > > I was wondering if someone could help me with the following problem. > > > > I am trying to perform an exponential fit to the following data > > {{x,y}} > > > > data > > ={{50,22},{64,62},{78,122},{93,269},{107,414},{122,507},{136,597}} > > > > Fit[data,Exp[x],x] > > > > what I get is > > > > 1.94272422061017735^-63 *E^x Which is not correct. > > > > With Excel I get 7.5*E^0.0034x which is correct. > > > > How can I do this with Mathematica ? > > > > Thanks. > > -Joseph. > > > > > >