help-octave
[Top][All Lists]

## Re: fit polynomial surface to 2d data?

 From: Jonathan C. Webster Subject: Re: fit polynomial surface to 2d data? Date: Fri, 06 Jul 2001 23:48:02 -0400

```george young wrote:

> I have an array of floating-point measurements on a square (5 by 5) 2d grid.
> I need to find any significant spatial trend, e.g. bigger on the
> left, bigger in the middle, etc.  I have many thousands of these data sets
> that need to be scanned for 'interesting' spatial variations, reporting the
> few that are beyond some criterion of flatness.
>

Make yourself  a set of  5 x 5 orthonormal test arrays, each testing a trend .
Each
dotted into itself and summed should be unity.  Each dotted into another and
summed
should be zero.  Maybe these are Legendre polynomials?   But you only have
enough
points for yery low orders.

QQ = sum( sum( ar_i .*  poly_j ) )

where ar_i is one of your  measuremant arrays and poly_j is one of your
orthonormal
set.

I think you have to separately measure and remove the mean of each of the ar_i.

octave:1> v = [-2:2]
v =

-2  -1   0   1   2

% rho relaxes the restrictions of reshape, and fills rows first.
octave:2>  ar = rho(v,5,5)
ar =

-2  -1   0   1   2
-2  -1   0   1   2
-2  -1   0   1   2
-2  -1   0   1   2
-2  -1   0   1   2

octave:3> d2 = sum( sum( ar .* ar))
d2 = 50
octave:4> poly_x= ar / sqrt(50)

poly_x  =

-0.28284  -0.14142   0.00000   0.14142   0.28284
-0.28284  -0.14142   0.00000   0.14142   0.28284
-0.28284  -0.14142   0.00000   0.14142   0.28284
-0.28284  -0.14142   0.00000   0.14142   0.28284
-0.28284  -0.14142   0.00000   0.14142   0.28284

% make tilt in y test poly
octave:5> poly_y = poly_x' ;

% tilt in x with itself

octave:6> sum(sum( poly_x  .*  poly_x))
ans = 1

% tilt in x with tilt in y
octave:7> sum(sum( poly_x  .*  poly_y ))
ans = 0
octave:8>

Anywhy, testing your measurement arrays with these prepared poly arrays should
find
the interesting cases.

Good luck.
Jonathan

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

```