[Top][All Lists]

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

Re: leasqr with bounds

From: Przemek Klosowski
Subject: Re: leasqr with bounds
Date: Fri, 26 Jan 2018 10:31:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/25/2018 10:09 PM, mrodrig wrote:
In order to test the operation of the leasqr function I tried with the

y= [10,8,5.5,3.5,0,1.2,2.5,4.6,7.5,9.8]
F=@(x, p) (p (1) * x .^ 2 + p (2) * x + p (3))
p = [a,b,c];

[f, pfit, kvg, iter, corp, covp, stdresid, Z, r2] = leasqr (Temp_bkg,
Int_Prom_bkg, par, F,tol, iter,wt, dp, dFdp);

and gives this results;
I did a lot of data fitting and so I'd like to help you on this. Thank you for providing the sample code you are working with---it makes it easy to engage. I think you mean to use x,y instead of what I assume are your original fitting data tables Temp_bkg and Int_Prom_bkg:

[f, pfit, kvg, iter, corp, covp, stdresid, Z, r2] = leasqr (x,y, par, F,tol, iter,wt, dp, dFdp)

because this gives the results you quote. Next, it seems, you need to do something like

options.bounds=[-5,5; -5,5; -1,1]
par=[1,1,1] # avoid exceeding the bounds in initial parameters
[f, pfit, kvg, iter, corp, covp, stdresid, Z, r2] = leasqr (x,y, par, F,tol, iter,wt, dp, dFdp, options)

and indeed we get no convergence.

I think that's because your function, with the parameter bounds you propose, will not fit the data. I concluded that by plotting your function with some values of parameters in your proposed range:

Perhaps I missed something, but I ran out of time I could spend on it because I had to start by figuring out the small problems with running the code from the problem as you posed it: that's why it's important to cross-check and test the code you are about to publish, so that others don't have to.

I think that you need to play with the function F and the parameter limits by plotting and inspecting it, to find the reasonable values of initial parameters, in the way I showed above. Good luck and please come back with more questions as you gain experience with this problem.



reply via email to

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