MathGroup Archive 2004

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

Search the Archive

Re: 3D fitting of data points


Tolonen, Ellen N wrote:
> Hello all,
> 
> I am trying to fit a set of 3D data points to a polynomial function 
> (a(1)x^2 + a(2)y^2+a(3)z^2 + a(4)xy + a(5)xz + a(6)yz + a(7)x + a(8)y + 
> a(9)z  - 1 = 0).   Is there a way to do three-dimensional fitting with 
> NonLinearFit?  And, if so, how?
> 
> Thanks,
> 
> Ellen
> entolonen at utep.edu


You are probably better off using a linear fit. THis can be done as 
below. We start with data points with random fluctuation from a 
particular polynomial in three variables.

data = Table[Module[{x,y,z}, {x,y,z} = Table[Random[Real,{-5,5}],{3}];
   {x,y,z,3*x^2+2*y^2-z^2+4*x*y-7*x*z-2*y*z-x+6*y+2*z-1+.05*Random[]}], 
{50}];

Now do the fit.

vars = {x,y,z};
basis = {x^2,y^2,z^2,x*y,x*z,y*z,x,y,z,1};
ffit = Fit[data, basis, vars];

last normalize so the constant term is -1 as per specification.

const = ffit /. {x->0,y->0,z->0};
Expand[-ffit/const]

YOu might also use FindFit to get the results for the fit parameters in 
a possibly more convenient form.


Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: how can I solve a function Erfc
  • Next by Date: Problem with transformation rules in Plot
  • Previous by thread: Re: how can I solve a function Erfc
  • Next by thread: Problem with transformation rules in Plot