gsl_fit
can be used to fit a single dataset.Choose from these 7 fitting methods and algorithms :
MULTIDIM_MINIMIZAION CONJUGATE_FR CONJUGATE_PR VECTOR_BFGS STEEPEST_DESCENT LEAST_SQUARES LMSDR LMDR SIMULATED_ANNEAL
Definition in file test_single.c.
Go to the source code of this file.
Functions | |
void | load (gsl_fit *gft, char *filename) |
Load the data. | |
int | main (int argc, char *argv[]) |
Main function. | |
Variables | |
double | d [3][2] |
void load | ( | gsl_fit * | gft, | |
char * | filename | |||
) |
Load the data.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
main
function.
Definition at line 47 of file test_single.c.
00048 { 00049 double param[4], error[4]; 00050 unsigned int fixed[4]; 00051 gsl_fit *my_gft=NULL; 00052 00053 /*======================================================== 00054 ** Prototype for how this might work: 00055 */ 00056 00057 /*======================================================== 00058 ** 1. Allocate and pick method from the several types available 00059 */ 00060 //my_gft = gsl_fit_alloc(LEAST_SQUARES, LMSDR, 100, SINGLE); 00061 my_gft = gsl_fit_alloc(MULTIDIM_MINIMIZAION, CONJUGATE_FR, 500, SINGLE); 00062 //my_gft = gsl_fit_alloc(SIMULATED_ANNEAL, 0, 0, SINGLE); 00063 00064 /*======================================================== 00065 ** 2. Load the data. 00066 */ 00067 load(my_gft, "test_data/data1.txt"); 00068 00069 /*======================================================== 00070 ** 4. Make an inital guess. 00071 */ 00072 param[0] = 10.472; fixed[0] = 0; 00073 param[1] = 20.627; fixed[1] = 0; 00074 param[2] = 6.150; fixed[2] = 0; 00075 param[3] = 1.150; fixed[3] = 0; 00076 gsl_fit_add_model_single(my_gft, spearson_area, param, fixed, 4); 00077 00078 param[0] = 9.323; fixed[0] = 0; 00079 param[1] = 70.033; fixed[1] = 0; 00080 param[2] = 3.704; fixed[2] = 0; 00081 param[3] = 15.150; fixed[3] = 0; 00082 gsl_fit_add_model_single(my_gft, spearson_area, param, fixed, 4); 00083 00084 param[0] = 0.0012; fixed[0] = 0; 00085 param[1] = 1.1000; fixed[1] = 0; 00086 gsl_fit_add_model_single(my_gft, sline, param, fixed, 2); 00087 00088 /*========================================================*/ 00089 gsl_fit_print(my_gft, "test_data/start.txt"); 00090 00091 /*======================================================== 00092 ** 5. Do the fitting 00093 */ 00094 gsl_fit_do(my_gft); 00095 00096 /*========================================================*/ 00097 gsl_fit_print(my_gft, "test_data/end.txt"); 00098 00099 /*======================================================== 00100 ** 6. Get the results 00101 */ 00102 gsl_fit_get_result(my_gft, 0, param, error, 4); 00103 gsl_fit_get_result(my_gft, 1, param, error, 4); 00104 gsl_fit_get_result(my_gft, 2, param, error, 2); 00105 00106 /*======================================================== 00107 ** 7. Free the container 00108 */ 00109 gsl_fit_free(my_gft); 00110 00111 return EXIT_SUCCESS; 00112 }