[Numpy-discussion] unexpected behaviour of numpy.var
Travis Oliphant
oliphant at ee.byu.edu
Tue Aug 1 15:54:46 EDT 2006
Sasha wrote:
>I cannot reproduce your results, but I wonder if the following is right:
>
>
>
>>>>a = array([1,2,3,4,5])
>>>>var(a[newaxis,:])
>>>>
>>>>
>array([ 0., 0., 0., 0., 0.])
>
>
>>>>a[newaxis,:].var()
>>>>
>>>>
>2.0
>
>
>>>>a[newaxis,:].var(axis=0)
>>>>
>>>>
>array([ 0., 0., 0., 0., 0.])
>
>Are method and function supposed to have different defaults? It looks
>like the method defaults to variance over all axes while the function
>defaults to axis=0.
>
>
>
They are supposed to have different defaults because the functional
forms are largely for backward compatibility where axis=0 was the default.
-Travis
More information about the NumPy-Discussion
mailing list