From: Geico Caveman on
Hello,

I have multipeak 1-D data that often takes a lot of steps to converge
after specifiying initial guesses. The fit ends up being rather good
most of the time, but sometimes, initial guesses are a little off, and
the fit goes haywire.

The whole fitting process takes a lot of time (typically - 3 minutes or
so per dataset, and I usually work with about 20-50 datasets in a
single run).

Is there a way to access intermediate parameters so that I can plot the
fit to give myself visual feedback on how the fitting is going ?

Thanks.

From: Steven_Lord on


"Geico Caveman" <spammers-go-here(a)spam.invalid> wrote in message
news:2010080916101916807-spammersgohere(a)spaminvalid...
> Hello,
>
> I have multipeak 1-D data that often takes a lot of steps to converge
> after specifiying initial guesses. The fit ends up being rather good most
> of the time, but sometimes, initial guesses are a little off, and the fit
> goes haywire.
>
> The whole fitting process takes a lot of time (typically - 3 minutes or so
> per dataset, and I usually work with about 20-50 datasets in a single
> run).
>
> Is there a way to access intermediate parameters so that I can plot the
> fit to give myself visual feedback on how the fitting is going ?

That depends on what function you're using to perform the fitting. If
you're using a function from Optimization Toolbox, look at the OutputFcn
option in the documentation for OPTIMSET.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Geico Caveman on
On 2010-08-10 08:51:38 -0500, "Steven_Lord" <slord(a)mathworks.com> said:

>
>
> "Geico Caveman" <spammers-go-here(a)spam.invalid> wrote in message
> news:2010080916101916807-spammersgohere(a)spaminvalid...
>> Hello,
>>
>> I have multipeak 1-D data that often takes a lot of steps to converge
>> after specifiying initial guesses. The fit ends up being rather good
>> most of the time, but sometimes, initial guesses are a little off, and
>> the fit goes haywire.
>>
>> The whole fitting process takes a lot of time (typically - 3 minutes or
>> so per dataset, and I usually work with about 20-50 datasets in a
>> single run).
>>
>> Is there a way to access intermediate parameters so that I can plot the
>> fit to give myself visual feedback on how the fitting is going ?
>
> That depends on what function you're using to perform the fitting. If
> you're using a function from Optimization Toolbox, look at the
> OutputFcn option in the documentation for OPTIMSET.

No. I am using a custom string consisting of mixed Gaussian and
Lorentzian peaks.

I am using something like (and the number of terms is user determined):

g1*exp(-((x-g2)/g3)^2) + l1*l2/((x-l3)^2+l2^2) + Gaussian 2 + Gaussian 3 etc.

I just want to find a way to access intermediate g1, l1, etc.

From: Steven_Lord on


"Geico Caveman" <spammers-go-here(a)spam.invalid> wrote in message
news:2010081011203216807-spammersgohere(a)spaminvalid...
> On 2010-08-10 08:51:38 -0500, "Steven_Lord" <slord(a)mathworks.com> said:
>
>>
>>
>> "Geico Caveman" <spammers-go-here(a)spam.invalid> wrote in message
>> news:2010080916101916807-spammersgohere(a)spaminvalid...
>>> Hello,
>>>
>>> I have multipeak 1-D data that often takes a lot of steps to converge
>>> after specifiying initial guesses. The fit ends up being rather good
>>> most of the time, but sometimes, initial guesses are a little off, and
>>> the fit goes haywire.
>>>
>>> The whole fitting process takes a lot of time (typically - 3 minutes or
>>> so per dataset, and I usually work with about 20-50 datasets in a single
>>> run).
>>>
>>> Is there a way to access intermediate parameters so that I can plot the
>>> fit to give myself visual feedback on how the fitting is going ?
>>
>> That depends on what function you're using to perform the fitting. If
>> you're using a function from Optimization Toolbox, look at the OutputFcn
>> option in the documentation for OPTIMSET.
>
> No. I am using a custom string consisting of mixed Gaussian and Lorentzian
> peaks.

That tells us what type of curve you're fitting. It doesn't tell us what
function you're using to fit that curve. Without that information, the best
advice I can give you is to have the function that evaluates your function
as part of the curve fitting DISP, FPRINTF, etc. the parameters with which
it was called. Depending on what functions you're using, there may be
better approaches (like the OutputFcn option I suggested above.)

> I am using something like (and the number of terms is user determined):
>
> g1*exp(-((x-g2)/g3)^2) + l1*l2/((x-l3)^2+l2^2) + Gaussian 2 + Gaussian 3
> etc.
>
> I just want to find a way to access intermediate g1, l1, etc.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Richard Willey on
Stu Kozola did a really nice webinar titled Global Optimization with MATLAB

One of his demos showed how to apply multistart to a curve fitting problem.
(This might be an easier way to skin this particular cat)

You can download all the code from

http://www.mathworks.com/matlabcentral/fileexchange/27178-global-optimization-with-matlab