Generating best-fit line formula for arbitrary list
- To: mathgroup at smc.vnet.net
- Subject: [mg103370] Generating best-fit line formula for arbitrary list
- From: Kelly Jones <kelly.terry.jones at gmail.com>
- Date: Fri, 18 Sep 2009 05:38:02 -0400 (EDT)
Mathematica's Fit function can find the best-fit line for a given List: Fit[Table[Prime[n],{n,1,20}],{1,x},x] I want Mathematica to spit out the formula for linear regression for an arbitrary list. This fails: Fit[s,{1,x},x] since "First argument s in Fit is not a list or a rectangular array". This works: t = Table[s[n],{n,1,20}] Fit[t,{1,x},x] but is ugly and unhelpful, since it mentions each of the 20 terms individually, and doesn't generalize to an arbitrary-size list. I'm looking for things like Mean[t] or Apply[Plus,t^2] in the answer. Can I make Mathematica give me the general formula here? -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile.
- Follow-Ups:
- Re: Generating best-fit line formula for arbitrary list
- From: Matthias Bode <lvsaba@hotmail.com>
- Re: Generating best-fit line formula for arbitrary list