MathGroup Archive 2003

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

Search the Archive

Re: Forcing a Fit through a Data Point (Mathematica 5)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43618] Re: Forcing a Fit through a Data Point (Mathematica 5)
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 23 Sep 2003 04:02:47 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <bkm7pa$rhj$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <bkm7pa$rhj$1 at smc.vnet.net>,
 Hank Shih <airforce1 at comcast.net> wrote:

> Hello all. I have a set of data for a experiment and I want to create 
> the best fit line. Based on the x-y coordinate system, I need the line 
> to go through (0, 0) no matter what. 

Note that this is generally bad practice: the fact that your best-fit 
line may not go through {0,0} actually tells you something useful -- 
that your calibration (zero-adjustment) may not be correct.

> The data is as followed: data = 
> {{0,0}, {.5,.25}, {1,.4}, {1.5,.5}, {2,.625}, {2.5,.84615}, {3,1}, 
> {3.5,1.0588}}.

Have you added the point {0,0} to your dataset or is this a measured 
value? Of course, adding {0,0} will not force the line to go through 
{0,0}.
 
> So far, to get the best fit I use:
> 
> data = {{0,0}, {.5,.25}, {1,.4}, {1.5,.5}, {2,.625}, {2.5,.84615}, 
> {3,1}, {3.5,1.0588}}.
> 
> abc = Fit[data, {1, x, x}, x]

You have a repeated x in the basis set. If you delete the constant term 
from the basis then you will get a linear fit that goes through {0,0}.

  Fit[data, {x}, x]

Another approach is to load <<Statistics` and use NonlinearFit. You can 
modify the weighting of the data points, inversely proportional, say, to 
their associated errors.

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Eigenvalues, any suggestions?
  • Next by Date: Re: Solve real roots only ?
  • Previous by thread: Re: Forcing a Fit through a Data Point (Mathematica 5)
  • Next by thread: Problems with Evaluate[]