MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Getting parameters from Fit[]..

  • To: mathgroup at
  • Subject: [mg27108] Re: Getting parameters from Fit[]..
  • From: "Paul Lutus" <nospam at>
  • Date: Sun, 4 Feb 2001 02:58:35 -0500 (EST)
  • References: <95gkss$>
  • Sender: owner-wri-mathgroup at

"Mark Harder" <harderm at> wrote in message
news:95gkss$8do at
>     I am doing a linear fit to obtain parameters for use in a larger,
> iterative procedure (a separable linear-nonlinear data fitting
> algorithm), and I'm trying to use Fit[] to do this.  Unfortunately, Fit
> does not return parameters by themselves, just the linear combination of
> my basis functions(which are much more complicated than the usual
> examples given in the documentation) weighted by the parameters.  I have
> tried various things, like using Regress instead of Fit, but that prints
> out at least a written report of the parameters every time it is
> invoked, which will make for a very cluttered output when included in
> the larger problem I am trying to solve.  I suppose I can find a method
> to isolate just the parts of the output of Fit that contain the
> parameters and process them to get the parameters, but that seems
> awkward and might introduce numerical errors.  I've looked at the
> MathGroup archives and found only 1 response to this question in the
> past, which was "Sorry, dont know how to do that. why don't you use
> Regress?".
>     Doesn't Mathematica provide any simple method for recovering just
> the parameter vector from a linear fit?  If it doesn't, perhaps it ought
> to.  Alternatively, is there some way to get Regress to provide the
> BestFitParameters rules without printing them out?  Or, is there some
> *simple* and accurate way of getting the parameters from the Fit output
> as is?

There are many ways to isolate specific parts of the output of a function
such as Fit[]. Perhaps you could post an example of your specific problem.
Using this example, one of us can show how to obtain a subset of the output.

And your use of the expression "parameters" is open to interpretation.
Perhaps this example will show you how to acquire specific values:

In[126]:= data = Table[Random[]+x+5,{x,0,10}]


In[166]:= fd = Fit[data, {1,x} ,x] (* m x + b form *)

Out[166]= 4.84769 + 0.949344 x

In[167]:= {b,m}= {fd[[1]],fd[[2,1]]}

Out[167]= {4.84769,0.949344}

Paul Lutus

  • Prev by Date: Re: Getting parameters from Fit[]..
  • Next by Date: Parametric Plot Again
  • Previous by thread: Re: Getting parameters from Fit[]..
  • Next by thread: Re: Getting parameters from Fit[]..