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

Home » Public Forums » archive » Locate an underflow
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Locate an underflow [message #25204 is a reply to message #25132] Thu, 24 May 2001 07:36 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
William Thompson wrote:
>
> Paul van Delst <paul.vandelst@noaa.gov> writes:
>
>> ... If, on running said code, I get a crapload of underflow errors, it's an
>> indication that that either a) the code hasn't been tested very well or b) the
>> programmer didn't really think about the problem enough ...
>
> I disagree. It's exceedingly easy to get underflow errors, and extremely
> difficult to program around them. For example, a simple Gaussian
>
> Y = A*exp(-((X-X0)/Sig)^2)
>
> is almost guaranteed to generate underflow errors. At some point this is going
> to be indistinguishable from zero. You'd have to jump through hoops to avoid
> getting the completely useless underfloat messages.

Not really. what about something like (assuming double precision):

tolerance = (MACHAR(/DOUBLE)).EPS

y = DBLARR( N_ELEMENTS( X ) )
xarg = ((X-X0)/Sig)^2
index = WHERE( xarg < tolerance, count )
IF ( count GT 0 ) THEN $
y = A*exp(-xarg[index])

Or, as I mentioned in my reply to Craig:

y = A * gaussian_function( (X-X0)/Sig )

(or similar) which contains all the bits and pieces for checking. Craig also provided a
method of avoiding the underflows.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: read Nexrad level 3 data
Next Topic: Re: read Nexrad level 3 data

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

Current Time: Fri Oct 10 14:17:47 PDT 2025

Total time taken to generate the page: 0.56003 seconds