[Numpy-discussion] matrix default to column vector?

Robert Kern robert.kern at gmail.com
Mon Jun 8 15:33:13 EDT 2009


On Mon, Jun 8, 2009 at 14:10, Alan G Isaac<aisaac at american.edu> wrote:
>>> Going back to Alan Isaac's example:
>>> 1)  beta = (X.T*X).I * X.T * Y
>>> 2)  beta = np.dot(np.dot(la.inv(np.dot(X.T,X)),X.T),Y)
>
>
> Robert Kern wrote:
>> 4) beta = la.lstsq(X, Y)[0]
>>
>> I really hate that example.
>
>
> Remember, the example is a **teaching** example.

I know. Honestly, I would prefer that teachers skip over the normal
equations entirely and move directly to decomposition approaches. If
you are going to make them implement least-squares from more basic
tools, I think it's more enlightening as a student to start with the
SVD than the normal equations.

> I actually use NumPy in a Master's level math econ course
> (among other places).  As it happens, I do get around to
> explaining why using an explicit inverse is a bad idea
> numerically, but that is entirely an aside in a course
> that is not concerned with numerical methods.  It is
> concerned only with mastering a few basic math tools,
> and being able to implement some of them in code is
> largely a check on understanding and precision (and
> to provide basic background for future applications).
> Having them use lstsq is counterproductive for the
> material being covered, at least initially.
>
> A typical course of this type uses Excel or includes
> no applications at all.  So please,
> show a little gratitude.  ;-)

If it's not a class where they are going to use what they learn in the
future to write numerical programs, I really don't care whether you
teach it with numpy or not.

If it *is* such a class, then I would prefer that the students get
taught the right way to write numerical programs.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list