[Numpy-discussion] matrix default to column vector?
Sat Jun 6 13:34:34 CDT 2009
I took that very seriously when you said that matrices were important to
you. Far from me the idea of forbidding numpy users to use matrices.
My point was the fact that newcomers are confused by the presence of both
matrices and arrays. I think that there should be only one
matrix/vector/tensor object in numpy. Therefore I would advocate the removal
of matrices from numpy.
*But* why not have matrices in a different component? Maybe as a part of
scipy? or somewhere else? You would be more than welcome to use them
anywhere. Note that I use components outside numpy for my teaching (scipy,
sympy, mayavi, nosetest) and I don't have any problems with that.
With my "argument" I endeavoured to explain the potential complications of
using matrices instead of arrays when teaching. Perhaps the strongest
argument against matrices is that you cannot use vectors. I've taught enough
matlab courses to realise the pain that this represents for students. But I
realise also that somebody else would have a different experience.
Of course x.T*y should be a 1x1 matrix, this is not an anomaly, but it is
confusing for students, because they expect a scalar. That is why I prefer
to teach with dot. Then the relation matrix/vector/scalar is crystal clear.
2009/6/5 Alan G Isaac <firstname.lastname@example.org>
> On 6/5/2009 11:38 AM Olivier Verdier apparently wrote:
> > I think matrices can be pretty tricky when used for
> > teaching. For instance, you have to explain that all the
> > operators work component-wise, except the multiplication!
> > Another caveat is that since matrices are always 2x2, the
> > "scalar product" of two column vectors computed as " x.T
> > * y" will not be a scalar, but a 2x2 matrix. There is also
> > the fact that you must cast all your vectors to column/raw
> > matrices (as in matlab). For all these reasons, I prefer
> > to use arrays and dot for teaching, and I have never had
> > any complaints.
> I do not understand this "argument".
> You should take it very seriously when someone
> reports to you that the matrix object is a crucial to them,
> e.g., as a teaching tool. Even if you do not find
> personally persuasive an example like
> I have told you: this is important for my students.
> Reporting that your students do not complain about using
> arrays instead of matrices does not change this one bit.
> Student backgrounds differ by domain of application. In
> economics, matrices are in *very* wide use, and
> multidimensional arrays get almost no use. Textbooks in
> econometrics (a huge and important field, even outside of
> economics) are full of proofs using matrix algebra.
> A close match to what the students see is crucial.
> When working with multiplication or exponentiation,
> matrices do what they expect, and 2d arrays do not.
> One more point. As Python users we get used to installing
> a package here and a package there to add functionality.
> But this is not how most people looking for a matrix
> language see the world. Removing the matrix object from
> NumPy will raise the barrier to adoption by social
> scientists, and there should be a strongly persuasive reason
> before taking such a step.
> Separately from all that, does anyone doubt that there is
> code that depends on the matrix object? The core objection
> to a past proposal for useful change was that it could break
> extant code. I would hope that nobody who took that
> position would subsequently propose removing the matrix
> object altogether.
> Alan Isaac
> PS If x and y are "column vectors" (i.e., matrices), then
> x.T * y *should* be a 1×1 matrix.
> Since the * operator is doing matrix multiplication,
> this is the correct result, not an anomaly.
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion