Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Exponential fit with weighted values
Replies: 7   Last Post: Nov 22, 2012 2:38 AM

 Messages: [ Previous | Next ]
 Sébastien MAILFERT Posts: 8 Registered: 6/9/11
Exponential fit with weighted values
Posted: Nov 21, 2012 2:18 AM

Hi,

I've data that I would like to fit with an exponential function, taking into account the error bars of the data.
Here are these data (xdata, error on xdata, y, error on ydata).
0.1483 0.000867 39.1945 1.8228
0.2168 0.001375 47.7910 1.7398
0.3473 0.002344 56.6020 2.2711
0.1567 0.000929 44.9017 2.0166
0.2703 0.001772 47.8569 1.8924
0.3166 0.002117 59.2465 2.3985
0.0496 0.000134 17.7732 0.9696
0.0732 0.000309 21.6460 0.9208
0.0953 0.000473 25.5399 0.8836
0.1290 0.000723 31.8719 1.4389
0.0570 0.000189 19.3770 0.5574
0.0815 0.000370 23.9318 0.7946
0.1129 0.000604 29.4718 0.8592
0.2012 0.001260 50.5815 2.2698
0.3777 0.002570 55.1597 1.8300

Here is my 2 Matlab codes:
----------------------------------------------------------------------
func=@(p,x) p(1)*(1-exp(-x*1000/(4*p(1)*p(2))));
init_param=[50 1];
ExpoResult1=lsqcurvefit(func,init_param,xdata,ydata);
----------------------------------------------------------------------

or
----------------------------------------------------------------------
function f=exponential(a,x)
f=a(1)*(1-exp(-x*1000/(4*a(1)*a(2))));
end
ExpoResult2=nlinfit(xdata,ydata,@exponential,[50 1]);
----------------------------------------------------------------------

These cades provide 2 results (close to each other, not exactlu equal)
ExpoResult1: [64.9797 0.6415]
ExpoResult2: [64.9801 0.6415]

My question is: How can I take into account the error bars in ydata (maybe a solution exists for the x values?) with a weighted fit?

Bioth of these two functions (lsqcurvefit and nlinfit) don't provide a possibility to enter the weighted values.
In Octave, you have this function: leasqr
(http://octave.sourceforge.net/optim/function/leasqr.html):
function [f,p,cvg,iter,corp,covp,covr,stdresid,Z,r2]=
leasqr(x,y,pin,F,{stol,niter,wt,dp,dFdp,options})
Where wt are the weighted values in ydata.

Can someone help me please?

Sébastien

Date Subject Author
11/21/12 Sébastien MAILFERT
11/21/12 Bruno Luong
11/21/12 Sébastien MAILFERT
11/21/12 Torsten
11/21/12 Bruno Luong
11/21/12 Torsten
11/21/12 Bruno Luong
11/22/12 Torsten