lsquares fitting and constrains for parameters (looking for positive values of parameters)
Subject: lsquares fitting and constrains for parameters (looking for positive values of parameters)
From: gwpublic at wp.pl
Date: Mon, 16 Jan 2012 02:43:27 +0100
Hello,
I use least squares method to fit functions to data :
load(lsquares)$
DataM: matrix( [1,1], [4,4], [10,9] );
lsquares_estimates (DataM, [x,y], y = a2*x**2 + a1*x + a0, [a2,a1,a0],
iprint=[-1,0]);
Maxima finds negative solutions:
(%i) grind(%);
(%o) [[a2 = -1/54,a1 = 59/54,a0 = -2/27]]$
What should I do to constrain parameters ?
To be more specific :
* I must ensure all are positive : a2>=0 a1>=0 a0>=0
* would be nice to specify upper limits as well : a2<maxa2 a1<maxa1 a0<maxa0
* Maybe other constrains if solution can handle any predicate.
But only "must" is to make them positive.
I've tried : "assume()", but with no success.
Any hint?
--
Best,
Grzegorz Wierzowiecki