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

Home » Public Forums » archive » Re: Inconsistent Mean Calculation
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: Inconsistent Mean Calculation [message #30828] Tue, 21 May 2002 10:39
plmcelwee is currently offline  plmcelwee
Messages: 6
Registered: April 2002
Junior Member
"Mark Hadfield" <m.hadfield@niwa.co.nz> wrote in message news:<accajn$q28$1@newsreader.mailgate.org>...
> "Phil" <plmcelwee@yahoo.com> wrote in message
> news:a3589d11.0205201557.1a92499f@posting.google.com...
>> I have 5000 frames of video in a NetCDF file, and I want to
>> calculate the average of frame 2557. I have read the video file
>> into both IDL v5.1 and Matlab v6.1. Additionally I have extracted
>> frame 2557 and copied it into Excel. Here are the mean calculations
>> I get for this frame:
>>
>> Matlab: 4092.6805
>> Excel: 4092.6805
>> IDL: 4093.6165
>>
>> Can anyone offer any suggestions as to why the IDL calculation is
>> different?
>
> Matlab uses double-precision real numbers whereas IDL by default uses
> single-precision. Try repeating your IDL calculations using
> double precision (for example, if you are using IDL's TOTAL function,
> set its DOUBLE keyword).


Mark and Ken, thanks for the help! Using double precision I get

IDL: 4092.6804

This is certainly close enough for what I'm doing.
Re: Inconsistent Mean Calculation [message #30836 is a reply to message #30828] Mon, 20 May 2002 18:00 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Phil" <plmcelwee@yahoo.com> wrote in message
news:a3589d11.0205201557.1a92499f@posting.google.com...
> I have 5000 frames of video in a NetCDF file, and I want to
> calculate the average of frame 2557. I have read the video file
> into both IDL v5.1 and Matlab v6.1. Additionally I have extracted
> frame 2557 and copied it into Excel. Here are the mean calculations
> I get for this frame:
>
> Matlab: 4092.6805
> Excel: 4092.6805
> IDL: 4093.6165
>
> Can anyone offer any suggestions as to why the IDL calculation is
> different?

Matlab uses double-precision real numbers whereas IDL by default uses
single-precision. Try repeating your IDL calculations using
double precision (for example, if you are using IDL's TOTAL function,
set its DOUBLE keyword).

--
Mark Hadfield "Ka puwaha et tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)


>
Re: Inconsistent Mean Calculation [message #30837 is a reply to message #30836] Mon, 20 May 2002 18:59 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <a3589d11.0205201557.1a92499f@posting.google.com>,
plmcelwee@yahoo.com (Phil) wrote:

> I have 5000 frames of video in a NetCDF file, and I want to calculate
> the average of frame 2557. I have read the video file into both IDL
> v5.1 and
> Matlab v6.1. Additionally I have extracted frame 2557 and copied it
> into Excel. Here are the mean calculations I get for this frame:
>
> Matlab: 4092.6805
> Excel: 4092.6805
> IDL: 4093.6165
>
> Can anyone offer any suggestions as to why the IDL calculation is
> different? Maybe there is a bug in IDL 5.1? Yeah I know it's a
> really old version. :)

Excel is doing the calculation in double precision; Matlab probably
likewise. Try TOTAL(image, /DOUBLE)/n or MOMENTS(image, /DOUBLE) in IDL
and let us know what you get.

5.1 is really old? Oh, maybe it's me that's really old.

Ken
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Is there no NULL in IDL??
Next Topic: Re: "bootstrap" statistics

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

Current Time: Wed Oct 08 11:37:00 PDT 2025

Total time taken to generate the page: 0.00539 seconds