[Numpy-discussion] matrix default to column vector?
Olivier Verdier
zelbier at gmail.com
Sat Jun 6 14:34:34 EDT 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.
== Olivier
2009/6/5 Alan G Isaac <aisaac at american.edu>
> 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
> http://mail.scipy.org/pipermail/numpy-discussion/2009-June/043001.html
> 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.
>
> Cheers,
> 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
> Numpy-discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090606/7a9b26c2/attachment.html>
More information about the NumPy-Discussion
mailing list