 |
Least
summary
 |
least square fitting program 1,2,3 variables, with errors on points
|
instructions
 |
least makes a 1,2 or 3 parameter fit to a number of points : x, y, dy.
25/11 : program has been made a little smoother. New option is multiplication with sqrt of reduced Chi^2.
The fit function is :
1. a*f(x) 2. a*f(x)+b*g(x) or 3. a*f(x)+b*g(x)+c*h(x) or the exponential of 1 2 or 3. f,g,h can be chosen from the set 1, x, x^2 or ln(x). Some examples : 1 param, lin, f=1 : y=a : fit to constant 2 param, lin, f=1 g=x : standard linear y=a+bx 3 param, lin, f=1 g=x c=x*x : y=a+bx+cx^2 2 param, exp, f=1 g=lnx : y=exp(a+blnx)=Ax^b 3 param, exp, f=1 g=x h=lnx : y=x^c*exp(a+bx) etc, etc
Instructions :
Start with CLR, clearing registers and define
1. lin or exp of function 2. define f,g,h (once defined they remain defined until changed)
N times : x enter y enter dy press [+] last data point can be removed by [-]
After last data point press FIT and choose # of parameters
Then : a : a,da (in x,y regs..i.e. tos,nos) b : b,db (relevant if 2 or 3 param fit) c : c,dc (relevant if 3 param fit) X : chi^2, N, #param y(x) : extrapolated point, error of e.p. -D- : multiplies(error) with sqrt of reduced Chi^2
You can press FIT again to change # parameters, to test relevance of these.
If you find anything wrong or want to ask/comment please feel free to e-mail me. Hans Boggild
|
code
 |
RPN.2.z\least
[z]#'18'V{0v1+X@_v};
[a]r4*k3*-;
[b]r9g6g6g5g5Ca*g7r6g6r5Car8*-k6Ca*+;
[t]xc*g5*;
[s]ChCgCf1g5*xd+Xdg1g1*Ctxe+Xeg2g1*Ctxh+Xhg3g1*Ctxj+Xjg2g2*Ctxf+Xfg3g2*Ctxg+Xg
g3g3*Ctxi+Xixbg1*Ctxk+Xkg1xb*Ctxl+Xlg2xb*Ctxm+Xmg3xb*Ctxn+Xn
xhxfxfxeCaXoxjxixgxixhxfxgxfxeCbXpd1d1d1d1xtxd>(:Cp);
[f]xxCi;
[g]xyCi;
[h]xzCi;
[e]D'define f,g,h :|[f]|[g]|[h]|[done]|'c(CjXxCe:C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