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: [mg43598] Re: Forcing a Fit through a Data Point (Mathematica 5)
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Tue, 23 Sep 2003 04:01:42 -0400 (EDT)
  • References: <bkm7pa$rhj$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

data={{0,0},{.5,.25},{1,.4},{1.5,.5},{2,.625},{2.5,.84615},{3,1},{3.5,
        1.0588}};

To pass through the origin the form is y=a*x vice y=a*x+b.  Consequently, 
remove the constant term from the target functions, i.e., use {x} vice {1, x}

abc = Fit[data, {x}, x]

0.324176 x

Needs["Graphics`Colors`"];

Plot[abc,{x,0,5},
    PlotStyle->Green,
    GridLines->Automatic,
    AxesLabel->{"Time\n(sec)","  Change in\nDistance (cm)"},
    Epilog->{Red,PointSize[0.02],Map[Point,data]},
    ImageSize->400];


Bob Hanlon

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

<< 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. 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}}.

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]
Plot[abc, {x, 0, 5}, GridLines -> Automatic, AxesLabel -> {"Time (in
       sec)", "Change in Distance (in cm)"},
   Epilog -> {PointSize[0.02], Map[Point, data]}]

Is there a easier way to do this through Mathematica 5? If not, how can 
I force it through that (0, 0) point? >><BR><BR>


  • Prev by Date: Mathematica commands needed to solve problem in Set Theory!
  • Next by Date: how import data to mathematica????
  • Previous by thread: Re: Forcing a Fit through a Data Point (Mathematica 5)
  • Next by thread: Re: Forcing a Fit through a Data Point (Mathematica 5)