MathGroup Archive 2003

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

Search the Archive

Re: Mathematica and polynomial surface fitting...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40927] Re: [mg40891] Mathematica and polynomial surface fitting...
  • From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
  • Date: Thu, 24 Apr 2003 05:29:38 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

data = Flatten[Table[{x, y, 1 + y^2 + x +
        x*y - x^2}, {x, -1, 1, 0.1}, {y, -1, 1, 0.1}], 1];

fitters =
    Table[x^i y^j, {i, 0, #}, {j, 0, # - i}] &;
fitTable[data_, order_] := Block[{f},
    f = Chop@Fit[data, Flatten@fitters@order, {x, y}];
    TableForm@Table[Coefficient[Coefficient[f, y, i], x, j],
       {i, 0, order}, {j, 0, order - i}]
    ]
fitTable[data, 2]

Bobby

-----Original Message-----
From: Fabio Rojas <fab at soda.csua.berkeley.edu>
To: mathgroup at smc.vnet.net
Subject: [mg40927] [mg40891]  Mathematica and polynomial surface fitting...

Here is my problem - can mathematica do it? Math is easy, but
finding software that produces easy to manipulate data is the issue...

1. The Data: Three columns vectors - X coords, Y coords and Z coords -
the data you need to do a surface plot.

2. Find the best polynomial fit f(X,Y)=Z of degree less than N.

3. Create new colums vectors that

	(a) report the coefficients and powers of each pure and mixed term;

	(b) create some new columns telling me which terms I used- so I can
	tell if it was X rather than XY that was used

In other words, augment [X|Y|Z] --> [X|Y|Z|Coeffs|powers]

4. Repeat this procedure many times - do the poly fit for same (X,Y) 
grid
but different Z values. Thus, I need an easy to manipulate output.

________________________________________________________________

Of course, lots of software can do poly fits, but few packages will 
give me
what I need for step 3 -  a nice vector/list that I can attach to each
version of the grid.

For example, Stata will do a polynomial fit, with logarithms you can't 
remove,
but it produces a confusing list of numbers (you can't tell the 
difference
between x^2 and X^2*log(x) - they are coded as "2 2" - annoying!). 
Other
data software will print on the screen the poly eqn, but you can't
attach it to your data. No object is produced that is easy to access.

So can mathematica help me with my problem? Please, let the answer be 
yes...

Fabio 


  • Prev by Date: RE: Sheer frustration with integration of piecewise continuous functions
  • Next by Date: Re: Sheer frustration with integration of piecewise continuous functions
  • Previous by thread: RE: troubles with Transformation Rules (Version 3)
  • Next by thread: Re: Mathematica and polynomial surface fitting...