[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] simple nonlinear fit

From: Long Vu
Subject: [Help-gsl] simple nonlinear fit
Date: Thu, 27 Aug 2009 22:00:54 -0500


I am new to GSL and new to nonlinear fit as well. I would like to use
the nonlinear fit of GSL, could you please help?

 I have a data set as follows:
x       f(x)
800   0.0290073021087
750   0.0555646715288
700   0.106436396964
650   0.203883264078
600   0.390546716694
550   0.748108181465
500   1.43303176612
450   2.74503085727
400   5.258218684
350   10.0723325771
300   19.2939642948
250   36.9583763602
200   70.7952788921
150   135.611247219
100   259.768880922
50   497.597897513
0   953.169089118

and I would like to fit this data set with an exponential function: y
= f(x) = a * exp(-b*x) + c. I installed GSL 1.11-2 on my Ubuntu 8.10.
I am able to run the example from
in my Eclipse. I compile, run and see the results. However, i check
the example and i see that it only allows me to input y (or f(x)) and
this example assumes that x increases from 0 to 39 (in method expb_df
(const gsl_vector * x, void *data, gsl_matrix * J)). I tried to change
the for loops in file expfit.c to represent my x values (from 0 to
800) and input y in the main file with my y values but the program
output no fit values at all. Also, in the example, there are guessed
values for the parameters A, lambda, b. What if we do not know the
guessed values and we input an arbitrary guessed values? Like in this
case, I do not know the guessed values of the parameters A, lambda, b.
How could I find the best fit?

I guess my fitting task is very simple (fit the above data set)
compared to the risk set of functionalities GSL can provide. So, there
might be some simple way for me to use GSL and fit my data set. Could
you please help?

Thank you very much,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]