[Numpy-discussion] matrix.std() returns array

Keith Goodman kwgoodman at gmail.com
Wed Apr 26 21:46:08 EDT 2006


I noticed that the mean of a matrix is a matrix but the standard
deviation of a matrix is an array. Is that the expected behavior? I'm
also getting the wrong values (0 and nan) for the standard deviation.
Did I mess something up?

I'm trying to learn scipy (and python) by porting a small Octave
program. I installed numpy from svn (today) on a Debian box. And
numpy.test() says OK.

Here's an example:

>> numpy.__version__
'0.9.7.2416'

>> x = asmatrix(random.uniform(0,1,(3,3)))

>> x

matrix([[ 0.56771284,  0.57053769,  0.57505946],
       [ 0.10479534,  0.81692248,  0.91829316],
       [ 0.48627829,  0.59255983,  0.32628573]])

>> x.mean(0)
matrix([[ 0.38626216,  0.66000667,  0.60654612]])

>> x.std(0)
array([        nan,  0.        ,  0.        ])




More information about the NumPy-Discussion mailing list