Re: Huh?? Stddev went crazy! [message #59854 is a reply to message #59853] |
Wed, 16 April 2008 12:31  |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
Conor wrote:
> I'd like to see someone explain this one. My stddev function
> apparently lost all grasp on reality?
>
> IDL> print,stddev([1,2,3,4,5])
> 3.07421 3.24566 3.08206 3.26360 2.97446
> IDL> print,stddev([1.,2.,3.,4.,5.])
> 3.07421 3.24566 3.08206 3.26360 2.97446
> IDL> print,stddev([1.,2.])
> 3.07421 3.24566
>
> IDL> print,stddev(findgen(32))
> 2.99513 3.07421 3.24566 3.08206 3.26360
> 2.97446 2.96850 3.04474 2.66875 2.77181
> 2.83465
> 2.77395 2.77370 2.87829 2.84716 2.86982
> 2.98503 2.93160 2.77602 2.59318 2.83169
> 3.30869
> 2.67353 3.15337 3.19076 3.19499 2.96050
> 3.13871 2.61707 2.77854 3.12603 3.20029
>
> Finally I did this:
>
> IDL> .reset
>
> And it returned to normal! Yeah!
>
> IDL> print,stddev(findgen(32))
> % Compiled module: STDDEV.
> % Compiled module: MOMENT.
> 9.38083
> IDL> res = findgen(10,10)
> IDL> print,stddev(res)
> 29.0115
>
> I have not been able to reproduce the crazy behavior since (not that
> I've tried very hard). Still, it's rather worrisome if the behavior
> of a built in function isn't reliable!!
Well, here I think I should point out that "stddev" is not a "built-
in"
function, but a "library" function (meaning it is distributed as
a .pro file).
Hence, anybody can override it by compiling a different function
called stddev. On the other hand, built-in functions
cannot be overridden in that way.
Paolo
|
|
|