[Numpy-discussion] deprecate numpy.matrix
josef.pktd at gmail.com
josef.pktd at gmail.com
Mon Feb 10 11:27:42 EST 2014
On Mon, Feb 10, 2014 at 10:09 AM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> On 2/9/2014 5:55 PM, alex wrote:
> > I'm working on the same kinds of problems in scipy development
> > (functions involving sparse matrices and abstract linear operators)
>
>
> And how is numpy's matrix object getting in your way?
> Your initial post simply treated the desirability of
> deprecation as a given and did not lay out reasons.
> A strong reason would be e.g. if the matrix object
> is creating a serious maintenance headache. Eliminating
> this should be a big enough gain to offset any lost interest
> in numpy from users of Matlab, GAUSS, IDL etc. from the
> disappearance of a user-friendly notation.
>
> I accept that a numpy matrix has some warts. In the past,
> I've proposed changes to address these. E.g.,
> https://www.mail-archive.com/numpy-discussion@scipy.org/msg06780.html
> However these went nowhere, so effectively the status quo was
> defended. I can live with that.
>
> A bit of the notational advantage of the `matrix` object was undercut
> by the addition of the `dot` method to arrays. If `matrix` is deprecated,
> I would hope that a matrix-power method would be added. (One that works
> correctly with boolean arrays and has a short name.) I ideally an inverse
> method would be added as well (with a short name). I think adding the
> hermitian transpose as `.H()` already has some support, but I forget its
> current
> status.
>
> Right now, to give a simple example, students can write a simple projection
> matrix as `X * (X.T * X).I * X.T` instead of
> `X.dot(la.inv(X.T.dot(X))).dot(X.T)`.
>
X.dot(la.pinv(X))
or even better assign pinv(X) to a name and reuse it.
Josef
(I never taught statistics or econometrics to undergraduates in Social
Sciences.)
How do we calculate the diagonal of the hat matrix without using N by N
matrices?
> The advantage is obvious and even bigger with more complex expressions.
> If we were to get `.I` for matrix inverse of an array (which I expect to be
> vociferously resisted) it would be `X.dot(X.T.dot(X).I).dot(X.T)` which
> at the moment I'm inclined to see as acceptable for teaching. (Not sure.)
>
> Just to forestall the usual "just start them with arrays, eventually
> they'll
> be grateful" reply, I would want to hear that suggestion only from someone
> who has used it successfully with undergraduates in the social sciences.
>
> Alan Isaac
>
> _______________________________________________
> 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/20140210/0204d508/attachment.html>
More information about the NumPy-Discussion
mailing list