SFIT Algorithm

Get genus, data, response and model spec. Set up arrays required for fitting Loop NITMAX/NUPDATE times all FIT_MIN performing NUPDATE iterations ype diagnostic info pdate model parameters in model_spec object loop ionally compute approximate errors for free parameters and write to model file play and optionally print the results

The fit optimisation is done by FIT_MIN - a combined gradient/quadratic-fitting minimisation routine based on the CURFIT program of Bevington. Parameter bounds are incorporated by 'pegging' parameters on bounds and excluding them from the fitting process until the fitstat gradient takes them back into the allowed region. 'FROZEN' parameters are never allowed to vary. Computing time is saved by using an approximation to the fitstat second derivs within FIT_DERIVS, rather than a rigorous evaluation. Details of the model prescription (though not the parameter values and bounds) and the observed and predicted data are not required by the main fitting routine itself, only by the routines which evaluate the fitstat value and its derivatives. These details (or in some cases pointers to them) are stored in FORTRAN structures (for neatness given the possibility of multiple datasets) and passed through FIT_MIN intact. For the spectral fitting case, a redshift may be incorporated by scaling all the model space bounds by 1+z, to shift them into the source frame.