Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: fitter.fitspoly - Function Up: fitter - Tool Previous: fitter.fitavg - Function


fitter.fitpoly - Function



Package utility
Module fitting
Tool fitter


Solve polynomial equations


Synopsis
fitpoly(n, x, y, sd, wt, id)


Arguments

n in the order of the polynomial to solve for
    Allowed: integer
x in the parameter for the polynomial calculations
    Allowed: one or more real or complex values
y in observed values of the condition equations
    Allowed: N x m values
sd in standard deviation of equations
    Allowed: one or more values used cyclically
    Default: unset
wt in an optional alternate for sd
    Allowed: one or more values used cyclically
    Default: 1
id in the id of a sub-tool
    Allowed: fitter id
    Default: 0


Returns
bool


Description
fitpoly will create normal equations from the specified condition equations, and solve the resulting normal equations. In essence a combination of makepoly and fit.

The method expects that the properties of the fitter to be used have been initialized or set (like the number of simultaneous solutions m; the type; factors). The main reason is to limit the number of parameters on the one hand, and on the other hand not to depend on the actual array structure in Glish to get the variables and type.



Example
- include 'fitting.g'
- fit := fitter();		# a fitter for real unknowns
- x:=[1:10]			# we have values at 10 'x' values
- y:=2+0.5*x-0.1*x^2		# which are 2 +0.5x -0.1x^2
- fit.fitpoly(3,x,y) 		# fit a 3-degree polynomial
T 
- print fit.solution(), fit.error() #  show solution and their errors
[2 0.5 -0.1 -6.21725e-14]  [0 0 0 0]

Note the big problem with polynomial fitting if you have relatively large x values: the internal precision of computers start to play a role. In general it is worth the effort to normalize x between -1 and 1. To aid in most standard cases, a function fitspoly has been provided.





next up previous contents index
Next: fitter.fitspoly - Function Up: fitter - Tool Previous: fitter.fitavg - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15