Question: Fit XYZ Data to Parabola with Statistics[Fit]

Hello,

i'd like to fit data of a Matrix M with M[x][y] = z(x,y) to a general parabola of the form: z=a*x^2+b*y^2+c*x+d*y+e

I'd like to use the statistics[Fit] package. Reading the documentation this should work but it doesn't

Please try the following code as example:

with(combinat);
with(Statistics);
M := randmatrix(5, 5);
XYValues := convert(sort(permute([seq(1 .. 5), seq(1 .. 5)], 2)), matrix);
ZValues := convert(Flatten(convert(M, listlist)), vector);
Fit(a*x^2+b*y^2+c*x+d*y+e, XYValues, ZValues, [x, y]);

Error, (in Statistics:-Fit) invalid input: PostProcessData expects its 1st argument, x, to be of type {array, list, rtable}, but received w

with(combinat);
with(Statistics);
V := randvector(30);
YValues := convert([seq(1 .. 30)], vector);
Fit(a*x^2+b*x+c, YValues, V, x);

Works fine!

 

Regards,

Tobias

Please Wait...