Re: naive question
- To: mathgroup at smc.vnet.net
- Subject: [mg92818] Re: naive question
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 14 Oct 2008 04:56:47 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <gcv7ku$e63$1@smc.vnet.net>
Francisco Gutierrez wrote: > I am using Fit within a function, and I want it to produce only a list of > coefficients, without the variables. > For example, if I plug into fit the following: Fit[{{1,2,3},{4,5,6},{7,8,9}},{1,x1,x2},{x1,x2}], > Mathematica produces: > 1.55556+0.555556 x1+0.444444 x2 > > I want to get only the following list: > {1.55556,0.555556,0.444444} > > It seem awfully simple, but I haven't managed. > How can I do it? Arguably, the easiest way would be to use *FindFit* as follows: In[1]:= {a, b, c} /. FindFit[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, a + b x1 + c x2, {a, b, c}, {x1, x2}] Out[1]= {1.55556, 0.555556, 0.444444} *FindFit* returns a list of replacement rules that are applied to the parameter names. (Note that the syntax for *FindFit* is slightly different from the syntax for *Fit*.) Regards, -- Jean-Marc