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

Home » Public Forums » archive » Question about tutorial in 1D Gaussian Filter
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
Question about tutorial in 1D Gaussian Filter [message #25929] Mon, 30 July 2001 00:30 Go to next message
coraluk is currently offline  coraluk
Messages: 2
Registered: July 2001
Junior Member
I want to use a 1D Gaussian Filter to fit a curve. After visiting the
tutorial about 1D Curve fitting in IDL, I still found some problems in
the function gauss1. Following are the questions:

1) What is the return of "size(x)"?

2) What is meant by "!dpi"?


Yours,
Cora
Re: Question about tutorial in 1D Gaussian Filter [message #26057 is a reply to message #25929] Tue, 31 July 2001 08:08 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
coraluk@hkpc.org (Cora) writes:
>> FUNCTION SIMPLEGAUSS, X, P
>> return, P(2)*EXP(-(X-P(0))^2/(2.*P(1)^2))
>> END

Hi Cora--

Here are the parameters P to SIMPLEGAUSS. Unlike GAUSS1, the final
parameter is simply the maximum value, not the area under the curve.
It's "simple" after all.

P(0) - position of centroid
P(1) - gaussian sigma
P(2) - maximum amplitude (not area of curve)

To use it, check out the tutorial, and try something like this:

p = mpfitfun('SIMPLEGAUSS', x, y, err, p0)
bestfit = simplegauss(x, p)

Much of this information is in the "frequently asked questions" for
the web page. Or, you can download MPFITPEAK, which is a function
specifically designed for fitting gaussian and other type peaks to
data. It automatically returns the best fit curve.

Craig

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

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Question about tutorial in 1D Gaussian Filter [message #26063 is a reply to message #25929] Mon, 30 July 2001 23:15 Go to previous message
coraluk is currently offline  coraluk
Messages: 2
Registered: July 2001
Junior Member
Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote in message news:<onr8uygjxs.fsf@cow.physics.wisc.edu>...
> coraluk@hkpc.org (Cora) writes:
>
>
>> I want to use a 1D Gaussian Filter to fit a curve. After visiting the
>> tutorial about 1D Curve fitting in IDL, I still found some problems in
>> the function gauss1. Following are the questions:
>>
>> 1) What is the return of "size(x)"?
>>
>> 2) What is meant by "!dpi"?
>
>
> Cora, GAUSS1 is my program, so perhaps I should respond.
>
> I should be clear first of all, that computing the gaussian *should*
> be as simple as EXP(-Z^2/2). Unfortunately, the exponential function
> is sensitive to underflow warnings. If Z is too large, then
> EXP(-Z^2/2) will underflow. My personal wish is that this would yield
> zero silently, but that is not what happens.
>
> All of the code you see in GAUSS1 is designed to avoid the warning,
> but maintain as much precision as possible. The SIZE function is used
> to determine the dimension and data type of a variable. I use it that
> function to decide whether the data is FLOAT or DOUBLE. You can look
> up !DPI in the manual under system variables.
>
> If you like, a function like the following one may be easier to
> understand, but will produce underflow warnings:
>
> FUNCTION SIMPLEGAUSS, X, P
> return, P(2)*EXP(-(X-P(0))^2/(2.*P(1)^2))
> END
>
> Good luck,
> Craig

Thank you for your answers. However, there are some follow up
questions after using the function simplegauss. (I have added some
checking to avoid underflow and overflow)

In the function simplegauss, I only need to input my X values, mean
and sd of Y, and the area. Then I get a bell shape of a gaussian
distribution. Is this a correct result of function simplegauss? If
yes, then how can this result apply to my data to get a best fit,
smooth curve.

Yours,
Cora
Re: Question about tutorial in 1D Gaussian Filter [message #26067 is a reply to message #25929] Mon, 30 July 2001 14:56 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
coraluk@hkpc.org (Cora) writes:


> I want to use a 1D Gaussian Filter to fit a curve. After visiting the
> tutorial about 1D Curve fitting in IDL, I still found some problems in
> the function gauss1. Following are the questions:
>
> 1) What is the return of "size(x)"?
>
> 2) What is meant by "!dpi"?


Cora, GAUSS1 is my program, so perhaps I should respond.

I should be clear first of all, that computing the gaussian *should*
be as simple as EXP(-Z^2/2). Unfortunately, the exponential function
is sensitive to underflow warnings. If Z is too large, then
EXP(-Z^2/2) will underflow. My personal wish is that this would yield
zero silently, but that is not what happens.

All of the code you see in GAUSS1 is designed to avoid the warning,
but maintain as much precision as possible. The SIZE function is used
to determine the dimension and data type of a variable. I use it that
function to decide whether the data is FLOAT or DOUBLE. You can look
up !DPI in the manual under system variables.

If you like, a function like the following one may be easier to
understand, but will produce underflow warnings:

FUNCTION SIMPLEGAUSS, X, P
return, P(2)*EXP(-(X-P(0))^2/(2.*P(1)^2))
END

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Question about tutorial in 1D Gaussian Filter [message #26070 is a reply to message #25929] Mon, 30 July 2001 13:44 Go to previous message
air_jlin is currently offline  air_jlin
Messages: 22
Registered: July 2001
Junior Member
hi Cora,


coraluk@hkpc.org (Cora) wrote in message
news:<b19810c5.0107292330.37dd66aa@posting.google.com>...
> I want to use a 1D Gaussian Filter to fit a curve. After visiting the
> tutorial about 1D Curve fitting in IDL, I still found some problems in
> the function gauss1. Following are the questions:
>
> 1) What is the return of "size(x)"?
>
> 2) What is meant by "!dpi"?
>
>
> Yours,
> Cora
>
SIZE returns information (e.g. array size, type, etc.) about the variable
x. !dpi is a system variable that contains the double precision value of
pi. for more info., both are described in more detail on the online help.

best,
-Johnny


-------------------------------------------
Johnny Lin
CIRES, University of Colorado
Work Phone: (303) 735-1636
Web: http://cires.colorado.edu/~johnny/
-------------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: plotting free form ascii data
Next Topic: New slackware 8.0 libraries, old executables?

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

Current Time: Wed Oct 08 18:41:48 PDT 2025

Total time taken to generate the page: 0.00431 seconds