comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Another MPFIT question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Another MPFIT question [message #62830] Sat, 11 October 2008 14:35 Go to next message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
Today I discovered MPFIT and I am so excited how well it works (many
thanks Craig!).

I ran into one problem, however, which I was not able to solve. Maybe,
there is a simple solution.
Among all the parameters I have four whose sum must not be larger than
a certain value:

0 < c1+c2+c3+c4 < 1.

All four parameters may vary between zero and one which I implemented
using .limits and .limited. But, how do I implement the additional
constraint? Any ideas? It may be too obvious for me to see...

Thanks, Michael
Re: Another MPFIT question [message #62878 is a reply to message #62830] Tue, 14 October 2008 02:26 Go to previous messageGo to next message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
> You may be able to cheat.  You could append a special data point which
> contributes "badness" whenever the parameters go outside of their
> desired bounds.  For example, if you have 100 data points, you would
> append a 101st residual, computed something like this,

Thanks, Craig! I'll try it out tonight and report back how well it
worked in my case.

Mchael
Re: Another MPFIT question [message #62911 is a reply to message #62830] Mon, 13 October 2008 03:06 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
MichaelT <michael.theusner@googlemail.com> writes:

> Today I discovered MPFIT and I am so excited how well it works (many
> thanks Craig!).
>
> I ran into one problem, however, which I was not able to solve. Maybe,
> there is a simple solution.
> Among all the parameters I have four whose sum must not be larger than
> a certain value:
>
> 0 < c1+c2+c3+c4 < 1.
>
> All four parameters may vary between zero and one which I implemented
> using .limits and .limited. But, how do I implement the additional
> constraint? Any ideas? It may be too obvious for me to see...

The short answer is that MPFIT does not handle complex inequality
constraints, only simple box boundary constraints on each parameter.
Vince's suggestion of re-expressing with different parameters is a
good one, but as you discovered, all the constraints become difficult.

You may be able to cheat. You could append a special data point which
contributes "badness" whenever the parameters go outside of their
desired bounds. For example, if you have 100 data points, you would
append a 101st residual, computed something like this,

big = 100 ; Bigger than your biggest residual
cc = c1+c2+c3+c4 ; Total
cclimits = [0d, 1d] ; Limits on total
toler = 0.001d ; Tolerance on limits
yy = (1-tanh((cc-cclimits(0))/toler))/2 + (1+tanh((cc-cclimits(1))/toler))/2

resid[101] = big*yy

Since MPFIT simply tries to minimize residuals, the presence of one
more residual will be handled just fine. As long as the parameters
are within constraints, the 101st residual contributes nothing, but if
they begin to touch the constraint, resid[101] will start to grow, and
hopefully repel the fitter from going that direction. All untested of
course.

The TANH() functions make an inverse box-car shape, but with smooth
edges. The smoothness is key, otherwise the fitter will rightly fail
due to discontinuities.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: cbmarkwardt+usenet@gmail.com
------------------------------------------------------------ --------------
Re: Another MPFIT question [message #62937 is a reply to message #62830] Wed, 15 October 2008 04:22 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
MichaelT <michael.theusner@googlemail.com> writes:
> Hi again, I just tried it and it works perfectly! Thanks again!

Huh. That actually blows my mind. I've never tried that before!

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: cbmarkwardt+usenet@gmail.com
------------------------------------------------------------ --------------
Re: Another MPFIT question [message #62953 is a reply to message #62878] Tue, 14 October 2008 13:00 Go to previous messageGo to next message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
Hi again, I just tried it and it works perfectly! Thanks again!

Michel
Re: Another MPFIT question [message #63383 is a reply to message #62937] Thu, 06 November 2008 14:03 Go to previous messageGo to next message
jgrimmond is currently offline  jgrimmond
Messages: 4
Registered: September 2008
Junior Member
On 15 Oct 2008 07:22:32 -0400, Craig Markwardt
<craigmnet@REMOVEcow.physics.wisc.edu> wrote:

Craig,

> MichaelT <michael.theusner@googlemail.com> writes:
>> Hi again, I just tried it and it works perfectly! Thanks again!
>
> Huh. That actually blows my mind. I've never tried that before!
>
> Craig

You are mimicking the penalty function approach to
constraints! (Unless, I am really missing something
here ....).

jg
Re: Another MPFIT question [message #63478 is a reply to message #63383] Sat, 08 November 2008 08:23 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Nov 6, 5:03 pm, jgrimm...@yahoo.com wrote:
> On 15 Oct 2008 07:22:32 -0400, Craig Markwardt
>
> <craigm...@REMOVEcow.physics.wisc.edu> wrote:
>
> Craig,
>
>> MichaelT <michael.theus...@googlemail.com> writes:
>>> Hi again, I just tried it and it works perfectly! Thanks again!
>
>> Huh.  That actually blows my mind.  I've never tried that before!
>
>> Craig
>
> You are mimicking the penalty function approach to
> constraints! (Unless, I am really missing something
> here ....).

Right, I understand that. The mind-blowing part was that it worked on
the first try :-)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: quantum visualizations using IDL
Next Topic: MPFIT

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:48 PDT 2025

Total time taken to generate the page: 0.05261 seconds