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

Home » Public Forums » archive » Re: something (wrong?) with CONGRID?
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: something (wrong?) with CONGRID? [message #75805 is a reply to message #75804] Sun, 01 May 2011 21:13 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JP writes:

> I think I came across a bug with CONGRID, but I'll be happy to be shown wrong.
>
> in the following example all goes as expected:
>
> a = lindgen(95, 74)
> b = congrid(a, 95*10, 74*10)
> Histo_b = Histogram(b, BINSIZE=1)
> help, b
> minmax, Histo_b
>
> I get:
> B LONG = Array[950, 740]
> 100 100
>
> so far, so good, b is an array 10 times larger and wider than a and all the elements of a are repeated 100 times in b.
>
> now I change the size of the array a:
>
> a = lindgen(958, 745)
> b = congrid(a, 958*10, 745*10)
> Histo_b = Histogram(b, BINSIZE=1)
> help, b
> minmax, Histo_b
>
> This time I get:
> B LONG = Array[9580, 7450]
> 90 120
>
> the size of b is OK, but there are some elements repeated 90 times and some others repeated 120 times!!?? I was expecting again 100 and 100.
>
> If I go a bit further and do:
> Histo_b = REFORM(histo_b, 958, 745)
> cgIMAGE, histo_b, SCALE=1
>
> I can see that the values of a repeated 90 times (instead as 100 as expected) are in two columns to the right and the values repeated 120 times are in the last column to the right...
>
>
> Is there anything wrong with CONGRID or I am missing something there?

I don't know exactly why this is happening. But I have
seen enough of this kind of thing over the years to feel
confident that it is yet another (although interesting)
variation of the "sky is falling" phenomenon.

http://www.idlcoyote.com/math_tips/sky_is_falling.html

In other words, when the replication isn't exact, interpolation
has to play a role and computers just cannot represent every
number exactly. Some numbers must fall on the "razor's edge"
and this fact results in some slight imbalancing of the number
of repeats.

http://www.idlcoyote.com/math_tips/razoredge.html

I don't think there is anything particularly alarming about
this. It is really no different then learning that even
mathematical theories cannot be complete. It just means
that whatever we do, there is mystery in the world. I happen
to think that is *exactly* the way it should be. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: something (wrong?) with CONGRID?
Next Topic: Re: Book Tour Report

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

Current Time: Sat Oct 11 13:48:47 PDT 2025

Total time taken to generate the page: 0.86777 seconds