comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to do surface fit?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How to do surface fit? [message #10790] Tue, 27 January 1998 00:00 Go to next message
Gang Chen is currently offline  Gang Chen
Messages: 4
Registered: January 1998
Junior Member
Hi,

I am trying to fit a surface (probably 2nd degree polynomial:
z=a+b*x+c*y+d*x*x+e*xy+f*y*y) on a two dimensional grids with IDL. But it
seems to me that SFIT and SVDFIT would not serve my purpose: SFIT only
generates the values on those grids without giving the coefficients, and
it uses different format of polynomial (z=sum of k_i,j * x^i * y^j); While
SVDFIT works only for curve fit. Does anybody have any idea on how to do
this by simply calling some existing functions instead of writing more
complicate code?

Many thanks,
Gang Chen == gang@cochise.biosci.arizona.edu
Re: How to do surface fit? [message #10973 is a reply to message #10790] Thu, 29 January 1998 00:00 Go to previous message
Evilio del Rio is currently offline  Evilio del Rio
Messages: 17
Registered: December 1997
Junior Member
On Wed, 28 Jan 1998, Gang Chen wrote:

>> Use the KX keyword to SFIT, it will return an array of coefficients, in
>> your case:
>>
>> IDL> zfit = SFIT(z,2,KX=k)
>> IDL> help,k
>> COEFF FLOAT = Array[3, 3]
>>
>> They are calculated with the convention X= 0,...,NX and Y=0,...,NY
>> (so you must to make the needed conversion).
>
>
> HI Evilio,
>
> I really appreciate your help on this. It seems that it works the way I
> wanted. But I have another question: Since the default grids are set with
> X= 0,...,NX and Y=0,...,NY in the source code for SFIT, how can I do for a
> non-uniform grids (e.g., X=0, 1, 4, 5, 9, ..., and Y=3, 4, 7, 11, ..)?
> Do I have to resort to interpolation so that values at uniform grids can be
> distributed?
>
> Many thanks,
> Gang Chen == gang@cochise.biosci.arizona.edu
>

Humm... Well, in fact you could use multivarite linear fitting, this is
fine if you have low-degree polynimials. You should use the function

REGRESS

but you must prepare before the independent variables. Let's call u to the
REGRESS dependent variable (they call it Y in the doc) and v the set of
independient variables (X in the doc). The fit REGRESS does is:

u = const+a0*v0+a1*v1+...+an-1*vn-1

if you compare with your problem:

z = a+b*x+c*y+d*x*x+e*xy+f*y*y

you must set:
u <=> z
const <=> a
a0 <=> b, v0 <=> x
a1 <=> c, v1 <=> y
a2 <=> d, v2 <=> x*x
(etc...)

This is not strictly correct since the "independent" variables are not (x,
is strongly correlated with x^2, x*y, etc.) but it will work if your data
are not very abnormal. The correct procedure, however, should be an
improved SVDFIT so that it can accept multiple independent variables since
the values of "X" are only used to calculate the user-supplied function
FUNC (see IDL doc on SVDFIT and "Numerical Recipes in FORTRAN", ch. 15.4,
pag. 675).

Maybe we could suggest this change to RSI people.

Cheers,



____________________________________________________________ ________
Evilio Jose del Rio Silvan Institut de Ciencies del Mar
E-mail: edelrio@icm.csic.es URL: http://www.ieec.fcr.es/~evilio/
"Anywhere you choose,/ Anyway, you're gonna lose"- Mike Oldfield
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: problems with XInterAnimate
Next Topic: Private vs. shared colormaps in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:51:47 PDT 2025

Total time taken to generate the page: 0.00577 seconds