Find Docs

Astronomical Applications Department, U.S. Naval Observatory - Linear Least Squares (Page 5)

Wodocs >> Science : Astronomy >> Astronomical Applications Department, U.S. Naval Observatory Linear Least Squares Page 5
Astronomical Applications Department, U.S. Naval Observatory - Linear Least Squares
# model must be of the form Y = F(t[k],P), where P are parameters
# and t is the independent variable. The sumindex subscript [k] MUST
# be attached to t in the model equation. For example,
# leastsqrs( y=a+b*x[k], x, k, [a,b] );
# Also valid is
# leastsqrs( y[k]=a+b*x[k], x, k, [a,b] );
#---------------------------------------------------------------------
leastsqrs := proc( model::`=`, indepvar::name,
sumindex::name, params::list )

local chi2, y, i, t, partials, k, eqs, solset, T, Y,
replace_denominators, sums, YTsums, n, p, nmax, N,
Tcount, Scount, ispoly, Delta, delta, tmp, goodsols;
global _subslist, time0;

if not has(model,sumindex) then
ERROR("model must be of the form Y=F(t[i],P)");
fi;

time0 := time();

i := sumindex;
t := indepvar;
if not type(t,indexed) then
t := t[i];
fi;
y := lhs(model);
if not type(y,indexed) then
y := y[i];
fi;
chi2 := Sum((y-rhs(model))^2,i=1..N);
if type(rhs(model),polynom) then
ispoly := true;
else
ispoly := false;
fi;
debug_print(procname,"i,t,y,ispoly,chi2",4,i,t,y,ispoly,chi2);

#-----------------------
# calculate the partials
#-----------------------
debug_print(procname,"Forming the normal equations...",3);
partials := [];
for k from 1 to nops(params) do
partials := [ op(partials), diff(chi2,params[k])=0 ];
od;
if printlevel >= 4 then
debug_print(procname,"partials",4);
for p in partials do
print(p);
od;
fi;

#-------------------------------------------
# form the summation substitutions variables
#-------------------------------------------
sums := convert( select( (x,y)->op(0,x)=y,
Page 5

<< Previous       1 2 3 4 5 6 7 8 9 10 11 12 13 14 15       Next >>



Other Documents:
Sensitivity Integral, 3 D plot fits, lyap2, NAO 150, Rotate Vector, lyapcalc, wedges, Scifull, Precession Memo, Precession Maple, Curves 3 D, NOVAS 2004 Overview, NOVAS 2006 Overview, thesis, Ranson,


WODocs | |
All rights reserved. wodocs.comę 2009
WODocs


New Docs

Documents Category:
Arts (Design, Movies, Music, Radio, Television)
Automotive (Cars, Marine, Motorcycle, ATV, Snowmobiles)
Business (Biotechnology and Pharmaceuticals, Chemicals, Construction and Maintenance, Materials, Real Estate, Services)
Electronics (Computers, Motion Control, Power Supply)
Games (Board, Family, Party, Card, Construction, RC Toys)
Health (Animalm, Beauty, Healthcare, Medicine, Pharmacy, Surgery, Weight Loss)
Home (Accessories, Cooking, Decor and Design, Electrical, Family, Pets)
News (Newspapers, Sports, Television)
Recreation (Collecting, Hiking, Scouting, Survival, Travel)
Reference (Education, Libraries and Archives, Museums)
Science (Agriculture, Astronomy, Biology, Chemistry)
Shopping (Antiques and Collectibles, Clothing, Flowers, Food, Home and Garden)
Sports (Bicycle, Snowboard, Skiing, Other)