Re: Exponential fit question.
- To: mathgroup at smc.vnet.net
- Subject: [mg28001] Re: Exponential fit question.
- From: Martin Kraus <Martin.Kraus at informatik.uni-stuttgart.de>
- Date: Wed, 28 Mar 2001 02:40:29 -0500 (EST)
- Organization: Institut fuer Informatik, Universitaet Stuttgart
- References: <99pdg6$lft@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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. Hi Joseph, Fit calculates only coefficients for the functions you specify, i.e., the result will be of the form a*Exp[x] while you need something like a*Exp[b*x]. In order to do so you could apply Log to all data values and fit these logarithmic values to a linear function (a + b*x) and then form Exp[a + b*x] which is a*Exp[b*x]. data = {{50, 22}, {64, 62}, {78, 122}, {93, 269}, {107, 414}, {122, 507}, {136, 597}} data2 = N[Map[{#[[1]], Log[#[[2]]]} &, data]] Simplify[Exp[Fit[data2, {1, x}, x]]] This returns 5.22289*Exp[0.0379875*x] which is pretty good. (I think the 0.0034 above should be 0.034.) You may worry that Fit now minimized a quadratic deviation of the logarithmic values; however, in practice this is often desirable because the error of measurements often grows linearly with the data values. Hope this helps Martin Kraus