Discussion:
fit polynomial surface to 2d data?
george young
2001-07-06 20:26:39 UTC
Permalink
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.

My thought was to fit a 2'nd order polynomial with least-squares or some
such metric, and scan for coefficients bigger than some cutoff. I think
a paraboloid is probably as complex a surface as the small amount of data merits.

I found "polyfit", but that seems only to work on 1d data. Is there some
octave package for fitting a simple surface to 2d noisy data?

Is there some other approach anyone would suggest for the general task?
I'm not very experienced in data crunching, so any suggestion would
be appreciated.

I don't mind committing a lot of cpu to the task, if that helps.

-- George Young
MIT Lincoln Laboratory
--
I cannot think why the whole bed of the ocean is
not one solid mass of oysters, so prolific they seem. Ah,
I am wandering! Strange how the brain controls the brain!
-- Sherlock Holmes in "The Dying Detective"



-------------------------------------------------------------
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
-------------------------------------------------------------
Jonathan C. Webster
2001-07-07 03:48:02 UTC
Permalink
Post by george young
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
-------------------------------------------------------------

Continue reading on narkive:
Loading...