Good afternoon all relatively simple`question here from a mechanical standpoint.
I'm currently performing PCA and have successfully written a code that computes the covariance matrix and correlation matrix, and the associated eigenspectrum.
Now, I have created an array that represents the eigenvectors row wise, and i would like to compute the transformation C*v^t, where c is the observation matrix and v^t is the element wise entries of the eigen vector transposed.
Now, since some of these matrices are pretty big-i'd like to be able to tell python which row of the eigenvector matrix to mulitply C by. So far I have tried some of the numpy functions, but to no avail.
(for those of you wondering, i don't want to compute the matrix product of all the eigen vecotrs, i only need to multiply by a small subset of them-the ones associated with the largest eigenvalues)
Thanks!
To "slice" a vector of row
n
out of 2-dimensional arrayA
, you use a syntax likeA[n]
. If it's slicing columns you wanted instead, the syntax isA[:,n]
.For transformations with numpy arrays and vectors, the syntax is with matrix multiplication operator:
Note: If you're on older python version (< 3.5), you might not have
@
available yet. Then you'll have to use a functionnp.dot(array, vector)
instead of the operator.