gsl_fit.h File Reference


Detailed Description

Include this file in any program. It contains declarations of all the data structures and fucntions.

Definition in file gsl_fit.h.

Go to the source code of this file.

Data Structures

struct  _data
 The _data struct holds a data set to be fit. More...
struct  _meth
 The _meth struct determines which fitting method to call. More...
struct  _func
 The _func struct holds pointers to the user-supplied functions. More...
struct  _para
 The _para struct holds all of the paramters. More...
struct  _fitf
 The gsl_fit struct will be passed as void pointer to the fitting routines. More...

Typedefs

typedef _fitf gsl_fit
 The gsl_fit struct will be passed as void pointer to the fitting routines.

Enumerations

enum  _method { MULTIDIM_MINIMIZAION = 0, LEAST_SQUARES = 1, SIMULATED_ANNEAL = 2 }
 Flags for selecting the fiting method. More...
enum  _algorithm {
  CONJUGATE_FR = 0, CONJUGATE_PR = 1, VECTOR_BFGS = 2, STEEPEST_DESCENT = 3,
  LMSDR = 4, LMDR = 5
}
 Flags for selecting the fiting algotrithm. More...
enum  _type
 Flags for selecting whether single or multuple data sets are being fit. More...

Functions

gsl_fitgsl_fit_alloc (unsigned int method, unsigned int algotrithm, unsigned int max_iter, unsigned int type)
 Call this function to initate and zero the model.
int gsl_fit_add_dataset (gsl_fit *gft, double *xpt, double *ypt, double *sig, unsigned int num)
 Call this function to add a data set to be fit.
int gsl_fit_add_model_single (gsl_fit *gft, double(*fun)(double, double *), double *par, unsigned int *fix, unsigned int num)
 Call this function to add a model function when fitting single datasets.
int gsl_fit_add_model_multiple (gsl_fit *gft, double(*fun)(double, double *, unsigned int, unsigned int), double *par, unsigned int *fix, unsigned int num)
 Call this function to add a model function when fitting multiple datasets.
int gsl_fit_print (gsl_fit *gft, char *filename)
 Print out the current parameter fit.
int gsl_fit_do (gsl_fit *gft)
 Do the fit.
int gsl_fit_get_result (gsl_fit *gft, unsigned int function, double *par, double *err, unsigned int num)
 Get the results.
void gsl_fit_free (gsl_fit *gft)
 Free the gsl_fit.
int lstsq_main (void *void_gsl_fit_struct)
 The main function for performing method of least squares fitting.
int lstsq_fdf (const gsl_vector *parameters, void *void_gsl_fit_struct, gsl_vector *r, gsl_matrix *J)
 A routine which calculates the residuals $r_i$ and the Jacobian matrix.
int lstsq_f (const gsl_vector *parameters, void *void_gsl_fit_struct, gsl_vector *r)
 A routine which calculates the residuals $r_i$.
int lstsq_df (const gsl_vector *parameters, void *void_gsl_fit_struct, gsl_matrix *J)
 A routine which calculates the Jacobian matrix.
double lstsq_derivatives (double p, void *void_gsl_fit_struct)
 A routine which calculates $J_{i,j}$ with a new parameter.
int lstsq_status (gsl_fit *gft, int iteration, gsl_multifit_fdfsolver *s, gsl_matrix *c)
 A fitting status update printed to stderr.
int mdmin_main (void *void_gsl_fit_struct)
 The main function for performing multidimensional minimization.
void mdmin_fdf (const gsl_vector *parameters, void *void_gsl_fit_struct, double *f, gsl_vector *df)
 A routine which calculates the $\chi^2$ value and the gradient of $\chi^2$ together.
double mdmin_f (const gsl_vector *parameters, void *void_gsl_fit_struct)
 A routine which calculates the $\chi^2$.
void mdmin_df (const gsl_vector *parameters, void *void_gsl_fit_struct, gsl_vector *df)
 A routine which calculates the gradient of $\chi^2$.
double mdmin_derivatives (double p, void *void_gsl_fit_struct)
 A routine which calculates $\chi^2$ with a new parameter.
double mdmin_chisq (gsl_fit *gft)
 A routine which calculates $\chi^2$.
void mdmin_status (gsl_fit *gft, int iteration, gsl_multimin_fdfminimizer *s)
 A fitting status update printed to stderr.
int siman_main (void *void_gsl_fit_struct)
 The main function for performing simulated annealing.
double siman_energy (void *void_gsl_fit_struct)
 A routine which calculates $\chi^2$.
void siman_step (const gsl_rng *rng, void *void_gsl_fit_struct, double step_size)
 Step the paramters by a small, random amount.
void siman_copy (void *source, void *dest)
 Copies one gsl_fit into another.
void * siman_construct (void *void_gsl_fit_struct)
 Creates a clone of a gsl_fit.
void siman_destroy (void *void_gsl_fit_struct)
 Frees a gsl_fit.
double siman_metric (void *void_gsl_fit_struct1, void *void_gsl_fit_struct2)
void siman_print (void *void_gsl_fit_struct)
 Print out the current state of the solution.


Typedef Documentation

typedef struct _fitf gsl_fit

The GSL passes a void pointer to the required functions for evaluation. This means we can store all the data and paramters in a specially constructed struct in memory and pass a pointer to it. So here is the gsl_fit struct that contains three other structs, which contain the data, the parameters and the model functions.

All the parameters must be part of a single array, so as a result they are seperated from the model function to which they belong. Which parameters belong to which model function? That is stored in the function struct as the index. To get the parameters for any function i;

	gsl_fit tmp;
	unsigned int i;
	
	unsigned int start_index = tmp->func[i].idx;
	unsigned int end_index   = tmp->func[i].idx + tmp->func[i].num - 1;

	tmp->para.par[start_index]  //first parameter
	tmp->para.par[end_index]    //last parameter

The only place where it is needed to keep tack of which paramter is which is inside the user-supplied function that uses it, i.e. d->func.fun.


Enumeration Type Documentation

enum _method

Flags for selecting the fiting method.

Enumerator:
MULTIDIM_MINIMIZAION  Selects the multidimensional minimization method. See the section Multidimensional minimization.
LEAST_SQUARES  Selects the non-linear least squares method.
SIMULATED_ANNEAL  Selects the simulated annealing method.

Definition at line 27 of file gsl_fit.h.

00027              {
00028   MULTIDIM_MINIMIZAION = 0,
00029   LEAST_SQUARES        = 1,
00030   SIMULATED_ANNEAL     = 2,
00031 };

enum _algorithm

Flags for selecting the fiting algotrithm.

Enumerator:
CONJUGATE_FR  Selects the Fletcher-Reeves conjugate gradient algorithm of the multidimensional minimization method.
CONJUGATE_PR  Selects the Polak-Ribiere conjugate gradient algorithm of the multidimensional minimization method.
VECTOR_BFGS  Selects the Broyden-Fletcher-Goldfarb-Shanno conjugate gradient algorithm of the multidimensional minimization method.
STEEPEST_DESCENT  Selects the steepest descent algorithm of the multidimensional minimization method.
LMSDR  Selects the Levenberg-Marquardt algorithm from the scaled "lmder" routine from MINPACK.
LMDR  Selects the Levenberg-Marquardt algorithm from the unsacled "lmder" routine from MINPACK.

Definition at line 32 of file gsl_fit.h.

00032                 {
00033   CONJUGATE_FR     = 0,
00034   CONJUGATE_PR     = 1,
00035   VECTOR_BFGS      = 2,
00036   STEEPEST_DESCENT = 3,
00037   LMSDR            = 4,
00038   LMDR             = 5,
00039 };

enum _type

Flags for selecting whether single or multuple data sets are being fit.

Definition at line 40 of file gsl_fit.h.

00040            {
00041   NOTHING = 0,
00042   SINGLE = 1,
00043   MULTIPLE = 2,
00044 };


Generated on Fri Jan 19 14:54:26 2007 for gsl_fit by  doxygen 1.4.7