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

Home » Public Forums » archive » Re: Gauss2DFit 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
Re: Gauss2DFit question [message #19927] Tue, 09 May 2000 00:00
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Kenneth P. Bowman" <kbowman@null.net> writes:

> [[ This message was both posted and mailed: see
> the "To," "Cc," and "Newsgroups" headers for details. ]]
>
> In article <on3dnrl7o9.fsf@cow.physics.wisc.edu>, Craig Markwardt
> <craigmnet@cow.physics.wisc.edu> wrote:
>
>> http://cow.physics.wisc.edu/~craigm/idl/idl.html
>
> Thanks, Craig. I greatly appreciate the help.
>
> I was thinking of writing a GAUSS2DFIT replacement using the built-in
> Levenberg-Marquardt algorithm, LMFIT. Have you compared the built-in
> function with your LM algorithm? (For speed, accuracy, etc.?)

I haven't done any direct comparisons, but I would expect any better.
In the speed category it will definitely be a loser, since it does a
function call for *each* data point. For images that's a lot of
points!

MPFIT is based on MINPACK-1 which which was designed to handle more
difficult problems. I believe that LMFIT is descends from Numerical
Recipes which doesn't have that reputation.

Craig

P.S. MPFIT is not the end-all, be-all. It fails this problem
miserably, <http://www.maxthis.com/curviex.htm>, but I believe this is
because the initial trial function spans about 8 orders of magnitude.

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Gauss2DFit question [message #19928 is a reply to message #19927] Tue, 09 May 2000 00:00 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
[[ This message was both posted and mailed: see
the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <on3dnrl7o9.fsf@cow.physics.wisc.edu>, Craig Markwardt
<craigmnet@cow.physics.wisc.edu> wrote:

> http://cow.physics.wisc.edu/~craigm/idl/idl.html

Thanks, Craig. I greatly appreciate the help.

I was thinking of writing a GAUSS2DFIT replacement using the built-in
Levenberg-Marquardt algorithm, LMFIT. Have you compared the built-in
function with your LM algorithm? (For speed, accuracy, etc.?)

Ken
Re: Gauss2DFit question [message #19929 is a reply to message #19927] Tue, 09 May 2000 00:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"K. Bowman" <k-bowman@null.tamu.edu> writes:
> I'm trying to use the library routine GAUSS2DFIT to fit some smooth,
> blobby functions. My experience so far has been ... ah ... suboptimal.
> It does not converge quickly or well.
>
> Example (modified from the example in the manual):
>
...
> yfit = GAUSS2DFIT(z, b, /TILT) ;Fit the function
...

I hope you try MPFIT2DPEAK, which is a drop-in replacement for
GAUSS2DFIT, but is based on the MINPACK-1 family of more robust
fitting routines at my website. The only change I make was to the
function name, otherwise the invocation is the same:

yfit = MPFIT2DPEAK(z,b,/tilt)

MPFIT2DPEAK also has some other cool peak-like functions, and has all
the standard MPFIT-family bells and whistles. Of course you will need
to download MPFIT & MPFIT2DFUN, the service routines that make it go.

http://cow.physics.wisc.edu/~craigm/idl/idl.html

These are the results I got, much closer to what you probably want:

Should be: 5.0000 10.0000 21.3333 10.0000 64.0000 60.0000 0.7854
Is: : 5.0089 10.0095 21.3838 9.9872 64.0621 59.9459 0.7790

Alas, it took a little longer, but my philosophy is slower and right
is better than faster and wrong.

I should also mention that determining the parameters of a peak can be
pretty hard to do automatically, especially when noise is present. I
believe the approach implemented in MPFIT2DPEAK is actually quite a
bit more robust than that of GAUSS2DFIT, but still, it cannot be
perfect.

If you can, I strongly recommend supplying starting values that match
your problem. For example, if you know where the peak is roughly, or
the width of the peak, that can really help the peak finding process.

Good luck!

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Gauss2DFit question [message #19930 is a reply to message #19927] Tue, 09 May 2000 00:00 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <090520001530100771%k-bowman@null.tamu.edu>, K. Bowman <k-bowman@null.tamu.edu> wrote:

> xr = (xx - a[4])*COS(a[6]) - (yy - a[4])*SIN(a[6]) ;Rotate x
> yr = (xx - a[4])*SIN(a[6]) + (yy - a[4])*COS(a[6]) ;Rotate y

should be

xr = (xx - a[4])*COS(a[6]) - (yy - a[5])*SIN(a[6]) ;Rotate x
yr = (xx - a[4])*SIN(a[6]) + (yy - a[5])*COS(a[6]) ;Rotate y

but it doesn't fix the problem.

Ken
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Interpolating over faults
Next Topic: Gauss2DFit question

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

Current Time: Wed Oct 08 13:42:19 PDT 2025

Total time taken to generate the page: 0.00705 seconds