[Numpy-discussion] syntax for obtaining rank of two columns?

Tim Hochberg tim.hochberg at cox.net
Thu Jun 15 20:27:42 EDT 2006

JJ wrote:

>Hello.  I am a matlab user learning the syntax of
>numpy.  Id like to check that I am not missing some
>easy steps on column selection and concatenation.  The
>example task is to determine if two columns selected
>out of an array are of full rank (rank 2).  Lets say
>we have an array d that is size (10,10) and we select
>the ith and jth columns to test their rank.  In matlab
>the command is quite simple:
>In numpy, the best I have thought of so far is:
>linalg.lstsq(transpose(vstack((d[:,i],d[:,j]))), \
>ones((shape(transpose(vstack((d[:,i],d[:,j]))))  \
>Im thinking there must be a less awkward way.  Any
This isn't really my field, so this could be wrong, but try:

linalg.lstsq(d[:,[i,j]], ones_like(d[:,[i,j]]))[2]

and see if that works for you.


>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>Numpy-discussion mailing list
>Numpy-discussion at lists.sourceforge.net

More information about the NumPy-Discussion mailing list