# [Numpy-discussion] Identifying Colinear Columns of a Matrix

josef.pktd@gmai... josef.pktd@gmai...
Fri Aug 26 15:03:21 CDT 2011

```On Fri, Aug 26, 2011 at 2:57 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> On Fri, Aug 26, 2011 at 12:38 PM, Mark Janikas <mjanikas@esri.com> wrote:
>>
>> Charles!  That looks like it could be a winner!  It looks like you always
>> choose the last column of the U matrix and ID the columns that have the same
>> values?  It works when I add extra columns as well!  BTW, sorry for my lack
>> of knowledge… but what was the point of the dot multiply at the end?  That
>> they add up to essentially zero, indicating singularity?  Thanks so much!
>
> The indicator of collinearity is the singular value in d, the corresponding
> column in u represent the linear combination of rows that are ~0, the
> corresponding row in v represents the linear combination of columns that are
> ~0. If you have several combinations that are ~0, of course you can add them
> together and get another. Basically, if you take the rows in v corresponding
> to small singular values, you get a basis for the for the null space of the
> matrix, the corresponding columns in u are a basis for the orthogonal
> complement of the range of the matrix. If that is getting a bit technical
> you can just play around with things.

Interpretation is a bit difficult if there are more than one zero eigenvalues

>>> zt2 = np.vstack((zt, zt[2,:] + zt[3,:]))
>>> zt2
array([[ 1.  ,  1.  ,  1.  ,  1.  ,  1.  ],
[ 0.25,  0.1 ,  0.2 ,  0.25,  0.5 ],
[ 0.75,  0.9 ,  0.8 ,  0.75,  0.5 ],
[ 3.  ,  8.  ,  0.  ,  5.  ,  0.  ],
[ 3.75,  8.9 ,  0.8 ,  5.75,  0.5 ]])
>>> u,d,v = np.linalg.svd(zt2)
>>> d
array([  1.51561431e+01,   1.91327688e+00,   3.25113875e-01,
1.05664844e-15,   5.29054218e-16])
>>> u[:,-2:]
array([[ 0.59948553, -0.12496837],
[-0.59948553,  0.12496837],
[-0.51747833, -0.48188813],
[ 0.0820072 , -0.60685651],
[-0.0820072 ,  0.60685651]])

Josef

>
> <snip>
>
> Chuck
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
```