- #1
pisuke
- 3
- 0
Hello there,
I have to fit a one term exponential curve: y = a*exp(-b*t), and I have to implement the fitting procedure in a C program. Some days ago I discovered the GSL (GNU Scientific Library), and I told myself better later than never ;-)
When reading the GSL documentation and the implementation examples at http://www.gnu.org/software/gsl/man...-for-Nonlinear-Least_002dSquares-Fitting.html I gladly found that one of the examples is an exponential curve of the type y = a* exp(-b*t) + c, it means that with just a slight modification of the code I will get what I am looking for.
However, in the code there's something that I don't understand, the fitting procedure adds a term called sigma with a value of 0.1 in every calculation of the function, here is the explanation on the documentation:
Here is the code doing the stuff:
I don't know the reason and what is more important I don't know if I have to use such term in my own program.
I am not a mathematician, I come from the biologic field and I need to fit data which comes from light absorption measurements.
Hopefully can someone here give me a hand on that issue.
Thanks,
Pisuke
I have to fit a one term exponential curve: y = a*exp(-b*t), and I have to implement the fitting procedure in a C program. Some days ago I discovered the GSL (GNU Scientific Library), and I told myself better later than never ;-)
When reading the GSL documentation and the implementation examples at http://www.gnu.org/software/gsl/man...-for-Nonlinear-Least_002dSquares-Fitting.html I gladly found that one of the examples is an exponential curve of the type y = a* exp(-b*t) + c, it means that with just a slight modification of the code I will get what I am looking for.
However, in the code there's something that I don't understand, the fitting procedure adds a term called sigma with a value of 0.1 in every calculation of the function, here is the explanation on the documentation:
The following example program fits a weighted exponential model with background to experimental data, Y = A \exp(-\lambda t) + b. The first part of the program sets up the functions expb_f and expb_df to calculate the model and its Jacobian. The appropriate fitting function is given by,
f_i = ((A \exp(-\lambda t_i) + b) - y_i)/\sigma_i
Here is the code doing the stuff:
Code:
...
sigma[i] = 0.1;
...
for (i = 0; i < n; i++)
{
/* Model Yi = A * exp(-lambda * i) + b */
double t = i;
double Yi = A * exp (-lambda * t) + b;
gsl_vector_set (f, i, (Yi - y[i])/sigma[i]);
}
...
I don't know the reason and what is more important I don't know if I have to use such term in my own program.
I am not a mathematician, I come from the biologic field and I need to fit data which comes from light absorption measurements.
Hopefully can someone here give me a hand on that issue.
Thanks,
Pisuke