Can Maxima fit the data?




On Thu, 10 Jun 2010, Marek Pietrow wrote:

< Sorry I am beginner. Could you write me if it is possible for maxima to find
< coefficients of the curve, say, A+B*%e^(-C*x) from the list like
< [[x1,y1],[x2,y2],...]? What method of fitting is possible?
< Thank you. Marek Pietrow.
 
See the lsquares package.

Here is an example adapted from the help page:

(%i1) load (lsquares)$

/* generate artificial data */
(%i2) M : genmatrix (lambda([x,y], if y=1 then x else
.1*exp(-0.2*x)+2),10,2),numer;

(%o2) matrix([1,2.081873075307798],[2,2.067032004603564],
             [3,2.054881163609402],[4,2.044932896411722],
             [5,2.036787944117144],[6,2.03011942119122],[7,2.024659696394161],
             [8,2.020189651799466],[9,2.016529888822159],
             [10,2.013533528323661])

/* estimate the parameters: a=.1, b=-.2 c=2 */
(%i3) lsquares_estimates (M, [x,y], y=a*exp(b*x)+c, [a,b,c],
initial=[.2,.1,2], iprint=[-1,0]);

(%o3) [[a = .1010185361658323,b = -0.184635888015087,c =
1.997155985989317]]

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.