aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/README
blob: 56d72836ec6d545aa06f102f17591fd3eace6f70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
THE INLFIT PACKAGE

This subdirectory contains the routines of the interactive non-linear
least squares fitting package INLFIT. This package is layered on the NLFIT
package in MATH. NLFIT uses the Levenberg-Marquardt method to solve for
the parameters of a user specified non-linear equation. The user must supply
two routines. The first routine evaluates the function in terms of its
parameters. The second routine evaluates the function and its derivatives
in terms of its parameters. The user must also supply initial guesses for
the parameters and parameter increments, the list of parameters to be
varied during the fitting process, a fitting tolerance, and the maximum
number of iterations.

The entry points into the INLFIT package are listed below.

	  ininit - Initialize the fitting routines
	   inget - Get the value of an INLFIT parameter
	   input - Store the value of an INLFIT parameter
	  ingkey - Get the value of an INLFIT graphics/axis parameter
	  inpkey - Store the value of an INLFIT graphics/axis parameter
	   infit - Fit the function non-interactively
	  ingfit - Fit the function interactively
	inerrors - Compute the errors of the fit
	  infree - Free memory allocated by ininit

The calling sequences for the above routines are listed below. The [iprd]
stand for integer, pointer, real and double precision versions of each
routine respectively. [str] stands for string.

               in_init[rd] (in, address(func), address(dfunc), param, dparam,
	               nparams, plist, nfparams)
  [irdp]val = in_get[irdp] (in, param)
                   in_gstr (in, params, str, maxch)
              in_put[irdp] (in, param, val)
                   in_pstr (in, param, str)
                   in_gkey (in, key, axis, type, varnum)
                   in_pkey (in, key, axis, type, varnum)
               in_fit[rd]  (in, nl, x, y, wts, npts, nvars, wtflag, stat)
               ing_fit[rd] (in, gp, cursor, gt, nl, x, y, wts, names, npts,
	                     nvars, len_names, wtflag, stat)
             in_errors[rd] (in, nl, x, y, wts, npts, nvars, variance,
	                    chisqr, scatter, rms, errors)
               in_free[rd] (in)


The user supplied functions fnc and dfnc have the following calling
sequences.

	fnc (x, nvars, nparams, nparams, zfit)
       dfnc (x, nvars, params, dparams, nparams, zfit, derivs)

The addresses of the user supplied functions can be obtained with a call
to locpr as follows.

        address = locpr (fnc)

The user definition for the INLFIT package can be found in the file 
lib$pkg/inlfit.h and can be made available to user applications programs
with the statement "include <pkg/inlfit.h>".

The permitted values for the param argument are the following.

# Integer valued parameters (in_geti, in_puti)

define	INLFUNCTION		# Fitting function
define	INLDERIVATIVE		# Fitting function derivatives
define	INLNPARAMS		# Total number of parameters
define	INLNFPARAMS		# Number of fitting parameters
define	INLNVARS		# Number of variables
define	INLNPTS			# Number of variables
define	INLMAXITER		# Max. number of iterations
define	INLNREJECT		# Number of rejection iterations
define	INLNREJPTS		# Number of rejected points
define	INLUAXES		# User plot function
define	INLUCOLON		# User colon function
define	INLUFIT			# User fit function
define	INLOVERPLOT		# Overplot next plot ?
define	INLPLOTFIT		# Overplot fit ?
define	INLFITERROR		# Error fit code
define	INLGKEY			# Graph key


# Real/double valued parameters (in_get[rd], in_put[rd])

define	INLTOLERANCE		# Tolerance of convergence
define	INLLOW			# Low rejection value
define	INLHIGH			# High rejection value
define	INLGROW			# Rejection growing radius


# Pointer valued parameters (in_getp, in_getp)

define	INLNL			# NLFIT descriptor
define	INLPARAM		# Parameter vector
define	INLDPARAM		# Parameter change vector
define	INLPLIST		# Parameter list
define	INLREJPTS		# Rejected points
define	INLXMIN			# Minimum value for curve
define	INLXMAX			# Maximum value for curve
define	INLSFLOAT		# Floating point substructure
define	INLSGAXES		# Graphics substructure


# String valued parameters (in_gstr, in_pstr)

define	INLLABELS		# standard axis labels
define	INLUNITS		# standard axis units
define	INLFLABELS		# Function labels
define	INLFUNITS		# Function units
define	INLPLABELS		# Parameter labels
define	INLPUNITS		# Parameter units
define	INLVLABELS		# Variable labels
define	INLVUNITS		# Variable units
define	INLUSERLABELS		# User plot labels
define	INLUSERUNITS		# User plot units
define	INLHELP			# Help file name
define	INLPROMPT		# Help prompt


The permitted values for the key argument are the following.

# in_gkey, in_pkey

define	KEY_FUNCTION		# Function
define	KEY_FIT			# Fit
define	KEY_RESIDUALS		# Residuals
define	KEY_RATIO		# Ratio
define	KEY_NONLINEAR		# Non-linear part
define	KEY_VARIABLE		# Variable (user or default)
define	KEY_UAXIS		# User plot function
define	KEY_MIN			# Min. key type
define	KEY_MAX			# Max. key type

The permitted values for the axis argument are the following.

# in_gkey, in_pkey

define	INLXAXIS		# X axis
define	INLYAXIS		# Y axis


The permitted values of the weights flag argument wtflag input to
in_fit[rd] or in_gfit[rd], and the stat argument returned by in_fit[rd]
or in_gfit[rd] are defined in lib$math/nlfit.h. They can be included in
the user's application with the statement "include <math/nlfit.h>".
The values are listed below.

# Permitted values for wtflag

define	WTS_USER		# User supplied weights
define	WTS_UNIFORM		# Uniform weighting
define	WTS_CHISQ		# Chi-squared weighting
define	WTS_SCATTER		# Weights include computed scatter term

# Permitted values for stat

define	DONE			# Solution converged
define	SINGULAR		# Singular solution
define	NO_DEG_FREEDOM		# Too few points
define	NOT_DONE		# Solution did not converge.

Note the pointer to the NLFIT structure nl is returned by the in_fit[rd]
and in_gfit[rd] routines and input to the in_errors[rd] routine. This
pointer must be freed separately with a call to nl_free when the fitting
process terminates.