From: Timo B. <t.b...@gm...> - 2012-10-16 21:35:31
|
Hey guys & girls, I found a script on the net that uses leasqr to fit experimental data to a function and adapted it to my needs. Works like a charm =) I do still have some trouble with understanding/using the weighing properly and hoped maybe someone could help me out. Here is my situation: I have experimental x-y data, the process is roughly an exponential decay. As always with real life data, its noisy and especially in the tail of the exponential, the noise is a problem. I know the absolute size of noise, let's call this number "noize". What I am used to doing in experimental data fitting is to take the weighing factor for each y-point as the inverse of its relative error, i.e. noize/yvalue. But the "wt" used in leasqr has to be an N*N-matrix, where N is the number of y-values ... I am a bit confused as to how I would construct the proper wt-matrix for the problem at hand. Help would be much appreciated, thanks in advance, Timo |
From: Nir K. <nkr...@cc...> - 2012-10-16 22:09:08
|
Hi Timo, As far as I can tell from the documentation ( http://octave.sourceforge.net/optim/function/leasqr.html ), wt is an N*1 vector. If your estimated error standard deviation is constant and equal to noize, you would set wt = ones(n, 1) / noize Nir |
From: Timo B. <t.b...@gm...> - 2012-10-16 22:23:19
|
That works indeed, cheers Nir! I was confused because by default, wt is set to ones(size(y)) ... also from the documentation - which kind of clashed with the initial statement, that wt should be of the same dimension as y ... Anyways, thanks for the quick reply, I consider my problem fixed. Timo 2012/10/17 Nir Krakauer <nkr...@cc...>: > Hi Timo, > > As far as I can tell from the documentation ( > http://octave.sourceforge.net/optim/function/leasqr.html ), wt is an N*1 > vector. If your estimated error standard deviation is constant and equal to > noize, you would set wt = ones(n, 1) / noize > > Nir |
From: Olaf T. <i7...@t-...> - 2012-10-17 13:02:10
Attachments:
signature.asc
|
On Wed, Oct 17, 2012 at 12:23:12AM +0200, Timo Bretten wrote: > That works indeed, cheers Nir! > I was confused because by default, wt is set to ones(size(y)) ... also ones(size(y)) have the same dimensions as y > from the documentation - which kind of clashed with the initial > statement, that wt should be of the same dimension as y ... so there should be no clash of these statements. > Anyways, thanks for the quick reply, I consider my problem fixed. But for the record, you do not need to specify weights if they are constant. Olaf > Timo > > 2012/10/17 Nir Krakauer <nkr...@cc...>: > > Hi Timo, > > > > As far as I can tell from the documentation ( > > http://octave.sourceforge.net/optim/function/leasqr.html ), wt is an N*1 > > vector. If your estimated error standard deviation is constant and equal to > > noize, you would set wt = ones(n, 1) / noize > > > > Nir > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev -- public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net |
From: Timo B. <t.b...@gm...> - 2012-10-17 13:20:41
|
Thanks Olaf, you are of course right. It was late yesterday and I didn't take enough time to actually think before asking. Maybe I wasn't clear in the discription of my problem. The absolute error is the same for every data-point, i.e. I measure voltages something like 0.10 +/- 0.05 V, the +/-0.05 stays the same for each x-y pair (this is waht I called "noize" in my initial eMail). In the tail of the exponential, the voltages I measure are small, like 0.06 +/- 0.05 V and thus have a much greater relative error associated with them. In my fit, I want those low, tail voltage values to be weighted less strongly. Actuallly the weight w_i for data point y_i should be equal to (y_i / noize)^2, so can I just use wt=ones(size(y)).*(y/noize).^2 ? Thanks once more, Timo 2012/10/17 Olaf Till <i7...@t-...>: > On Wed, Oct 17, 2012 at 12:23:12AM +0200, Timo Bretten wrote: >> That works indeed, cheers Nir! >> I was confused because by default, wt is set to ones(size(y)) ... also > > ones(size(y)) have the same dimensions as y > >> from the documentation - which kind of clashed with the initial >> statement, that wt should be of the same dimension as y ... > > so there should be no clash of these statements. > >> Anyways, thanks for the quick reply, I consider my problem fixed. > > But for the record, you do not need to specify weights if they are > constant. > > Olaf |
From: Olaf T. <i7...@t-...> - 2012-10-17 18:53:52
Attachments:
signature.asc
|
On Wed, Oct 17, 2012 at 03:20:30PM +0200, Timo Bretten wrote: > Thanks Olaf, > you are of course right. It was late yesterday and I didn't take > enough time to actually think before asking. > > Maybe I wasn't clear in the discription of my problem. The absolute > error is the same for every data-point, i.e. I measure voltages > something like 0.10 +/- 0.05 V, the +/-0.05 stays the same for each > x-y pair (this is waht I called "noize" in my initial eMail). > In the tail of the exponential, the voltages I measure are small, like > 0.06 +/- 0.05 V and thus have a much greater relative error associated > with them. Actually I wouldn't take the greater _relative_ variance as a reason to assign different weights. > In my fit, I want those low, tail voltage values to be weighted less > strongly. Actuallly the weight w_i for data point y_i should be equal > to (y_i / noize)^2, so can I just use wt=ones(size(y)).*(y/noize).^2 ? The choice of weights is outside the scope of this optimization algorithm. Other weights than suggested in the help of leasqr can be reasonable (but I don't see this in your case, as I said). Only the reasonable computation of some additional statistics (corp, covp, covr, Z) depends on the specification of weights as suggested in the help text. I consider nonlin_residmin (or nonlin_curvefit) as preferable to leasqr (while their default backend algorithm is identical to that of leasqr). They delegate the computation of statistics into an extra function (residmin_stat) and so do not mention any restriction on the weights in their help text. Olaf > Thanks once more, > Timo -- public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net |