[Numpy-discussion] matrix default to column vector?
Sun Jun 14 11:20:51 CDT 2009
> On Mon, Jun 8, 2009 at 3:33 PM, Robert Kern<firstname.lastname@example.org> wrote:
>> On Mon, Jun 8, 2009 at 14:10, Alan G Isaac<email@example.com> 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)
>>>> I really hate that example.
I propose the following alternative for discussion:
U, s, Vh = np.linalg.svd(X, full_matrices=False)
1) beta = Vh.T*np.asmatrix(np.diag(1/s))*U.T*Y
2) beta = np.dot(Vh.T, np.dot(np.diag(1/s), np.dot(U.T, Y)))
1) is with X and Y starting out as matrices, 2) is with arrays.
Even diag results in an array that has to be matricized. Sigh.
View this message in context: http://www.nabble.com/matrix-default-to-column-vector--tp23652920p24023215.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
More information about the Numpy-discussion