[Numpy-discussion] unexpected behaviour of numpy.var
David L Goldsmith
David.L.Goldsmith at noaa.gov
Tue Aug 1 10:59:16 CDT 2006
Hi, Hanno. I ran your sample session in numpy 0.9.8 (on a Mac, just so
you know; I don't yet have numpy installed on my Windows platform, and I
don't have immediate access to a *nix box) and could not reproduce the
problem, i.e., it does appear to have been fixed in 0.9.8.
DG
Hanno Klemm wrote:
> Hello,
>
> numpy.var exhibits a rather dangereous behviour, as I have just
> noticed. In some cases, numpy.var calculates the variance, and in some
> cases the standard deviation (=square root of variance). Is this
> intended? I have to admit that I use numpy 0.9.6 at the moment. Has
> this been changed in more recent versions?
>
> Below a sample session
>
>
> Python 2.4.3 (#1, May 8 2006, 18:35:42)
> [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import numpy
>>>> a = [1,2,3,4,5]
>>>> numpy.var(a)
>>>>
> 2.5
>
>>>> numpy.std(a)
>>>>
> 1.5811388300841898
>
>>>> numpy.sqrt(2.5)
>>>>
> 1.5811388300841898
>
>>>> a1 = numpy.array([[1],[2],[3],[4],[5]])
>>>> a1
>>>>
> array([[1],
> [2],
> [3],
> [4],
> [5]])
>
>>>> numpy.var(a1)
>>>>
> array([ 1.58113883])
>
>>>> numpy.std(a1)
>>>>
> array([ 1.58113883])
>
>>>> a =numpy.array([1,2,3,4,5])
>>>> numpy.std(a)
>>>>
> 1.5811388300841898
>
>>>> numpy.var(a)
>>>>
> 1.5811388300841898
>
>>>> numpy.__version__
>>>>
> '0.9.6'
>
>
>
> Hanno
>
>
--
HMRD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/>
More information about the Numpy-discussion
mailing list