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

Home » Public Forums » archive » Re: mean() function
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: mean() function [message #46929 is a reply to message #46927] Tue, 10 January 2006 19:22 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <dq1gv6$v05$1@news.nems.noaa.gov>,
Paul Van Delst <Paul.vanDelst@noaa.gov> wrote:

> Kenneth Bowman wrote:
>> In article <1136932449.216202.42760@g44g2000cwa.googlegroups.com>,
>> biocpu@yahoo.com wrote:
>>
>>
>>> y = fltarr(1008879)+35
>>
>>
>> Looks like roundoff error to me
>>
>> IDL> y = fltarr(1008879)+35
>> IDL> print, mean(y)
>> 35.0497
>> IDL> print, mean(y, /double)
>> 35.000000
>> IDL> y = dblarr(1008879)+35
>> IDL> print, mean(y)
>> 35.000000
>
> Huh. I don't see this in single precision (see other post). What version of
> IDL did you use?
>
> paulv

The version I posted (quoted above) is

{ ppc darwin unix Mac OS X 6.2 Jun 20 2005 32 32}

If I run it on my PowerBook (now sadly obsolete ;-) ), which is running
6.1

{ ppc darwin unix Mac OS X 6.1 Jul 14 2004 32 32}

I get exactly what was in the original post (he was running 6.0 on IRIX)

IDL> y = fltarr(1008879) + 35
IDL> print, mean(y)
35.5249
IDL> print, mean(y, /double)
35.000000
IDL> print, version

I suppose math libraries or compilers changed between 6.1 and 6.2.

Once the values you are adding differ by 6-7 orders of magnitude,
precision is completely lost for single precision floats.

IDL> print, total(replicate(1.0, 10^7))
1.00000e+07
IDL> print, total(replicate(1.0, 10^8))
1.67772e+07
IDL> print, total(replicate(1.0D0, 10^8))
1.0000000e+08

Cheers, Ken
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: reading a ninary file
Next Topic: mean() function

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

Current Time: Sat Oct 11 06:27:19 PDT 2025

Total time taken to generate the page: 0.56315 seconds