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.fitavg - Function Up: fitter - Tool Previous: fitter.linear - Function


fitter.functional - Function



Package utility
Module fitting
Tool fitter


Solve a general fitting problem


Synopsis
functional(fnct, x, y, sd, wt, mxiter, id)


Arguments

fnct in functional to be fitted
    Allowed: a functional
    Default: unset
x in the x coordinate values
    Allowed: vector
y in the ordinate values
    Allowed: vector
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
mxiter in the maximum number of iterations
    Allowed: integer
    Default: 50
id in the id of a sub-tool
    Allowed: fitter id
    Default: 0


Returns
bool or fail


Description
functional will make a non-linear least squares solution for the points through the ordinates at the x values, using the specified fnct. Details can be found in the linear description.


Example
- include 'fitting.g'                   # create default fitter
- x := [1:10];                          # some x values
- y := 3*x*x;                           # some y values
- dfit.functional(dfs.poly(2), x, y);   # solve 2nd order polynomial
T
- dfit.solution();
[-1.10049e-15 7.44482e-16 3]  
- include 'functionals.g'               # allow functionals
- anonlin := function() {			# encapsulate some code
z:=dfs.compiled('p0+p1*x0+p2*x1')       # a 2-d functional
x:=[1,2,3,4,5,6]                        # 3 observations
z.setparameters([1,2,3])		# set parameters to get ys
print 'y=', y:=z.f(x)			
dfit.functional(z,x,y)			# fit
print 'non-linear:', dfit.solution()
z:=dfs.compiled('p0+p1*x0')             # try a 1-d funtional	
x:=[1,3,5]
z.setparameters([1,2])
print 'y=', y:=z.f(x)
dfit.functional(z,x,y)
print 'non-linear:', dfit.solution()
z:=dfs.compiled('6+p0')			# try a 0-d functional
x:=[]
print 'y=', y:=z.f([1:3])-2
dfit.functional(z,x,y)
print 'non-linear:', dfit.solution()
return T
}
- anonlin()
y= [9 19 29] 
non-linear [1 2 3] 
y= [3 7 11] 
non-linear [1 2] 
y= [4 4 4] 
non-linear -2
T





next up previous contents index
Next: fitter.fitavg - Function Up: fitter - Tool Previous: fitter.linear - 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