MathGroup Archive 2014

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

Search the Archive

Re: FindFit and LeastSquares

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132408] Re: FindFit and LeastSquares
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Mon, 10 Mar 2014 04:39:13 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

ClearAll[a,b,c,d,e]; s = FindFit[Append[#,0]&/@data, 
a*y^2 + b*x*y + c*x + d*y + e - x^2, {a,b,c,d,e}, {x,y}]

{a -> -2.63563, b -> 0.143646, c -> 0.551447, d -> 3.22294, 
 e -> -0.432894}

Block[{a,b,c,d,e}, {a,b,c,d,e} = {a,b,c,d,e}/.s; 
ContourPlot[a*y^2 + b*x*y + c*x + d*y + e - x^2, 
{x,0,1.03},{y,.11,.4}, Contours->{0}, ContourShading->False, 
 Prolog->{PointSize[.02],Point/@data}]]

----- Alexandra Lipson <lipson.alexandra at gmail.com> wrote:
> 
> Hello All,
> 
> I have an assignment to use Linear Least Squares to determine the orbital
> parameters given the following observations as (x,y)
> coordinates:  (1.02,.39), (.95,.32), (.87,.27), (.77,.22), (.67,.18),
> (.56,.15), (.44,.13), (.30,.12), (.16,.13), (.01,.15). I am asked to plot
> the resulting orbit for the given data points.
> 
> Here is what I have been playing with:
> 
> a1 = {{1.02, .39}, {.95, .32}};
> b1 = {{.87, .27}, {.77, .22}};
> c1 = {{.67, .18}, {.56, .15}};
> d1 = {{.44, .13}, {.3, .12}};
> e1 = {{.16, .13}, {.01, .15}};
> r = ListPlot[{a1, b1, c1, d1, e1}]
> points = {{a1}, {b1}, {c1}, {d1}, {e1}};
> data = {{1.02, .39}, {.95, .32}, {.87, .27}, {.77, .22}, {.67, .18}, {.56, \
> .15}, {.44, .13}, {.3, .12}, {.16, .13}, {.01, .15}}
> 
> model = a*y^2 + b*x*y + c*x + d*y + e - x^2
> FindFit[data, model, {a, b, c, d, e}, {x, y}]
> l = LeastSquares[{a1, b1, c1, d1, e1},_]
> 
> I've been getting the error that FindFit is not a list or a rectangular
> array, among others.
> 
> I was wondering you have any suggestions.
> 
> Thanks!
> 
> Alexandra Lipson



  • Prev by Date: Re: FindFit and LeastSquares
  • Next by Date: Re: matrix manipulation
  • Previous by thread: Re: FindFit and LeastSquares
  • Next by thread: Re: FindFit and LeastSquares