I have an iteration whose steps extract a matrix with any possible dimension for example 3*3, 6*6, 10*10 , 4*4 ... . In any iteration I have eigenvalues and eigenvectors of the matrix extracted, for example {10^-6, 10^-4, 10^-3, 0.1, 0.4}. I wish to keep eigenvectors corresponding to just {10^-3, 0.1, 0.4}.

In fact with the below code I could sort eigenvalues and corresponded eigenvectors:

{eivals, eivecs} = Eigensystem[matrix];
{eivals, eivecs}= {eivals[[#]], eivecs[[#]]} &@ Ordering[eivals];

But, when I want to use

desiredeigenvecs=Drop[eivecs, x]

I do not know how I insert a suitable x to keep eigenvectors according to the important eigenvalues except the first unimportant eigenvalues?!!

  • 2
    $\begingroup$ In this context, how do you define "important" and "unimportant"? It seems from your comment on @HenrikShumacher's post that you do not know what the threshold should be, so we can't possibly know either? Can you explain what you really mean here? $\endgroup$
    – march
    Jan 9, 2020 at 17:12
  • 2
    $\begingroup$ This critically depends on how you define important vs. unimportant. For instance, I could say that the only "unimportant" eigenvalue in your list is 10^-6; you, on the other hand, seem to have decided that the first unimportant one is 10^-3. That choice is arbitrary, so you have to come up with an appropriate rule yourself. $\endgroup$
    – MarcoB
    Jan 9, 2020 at 17:12
  • $\begingroup$ Yes, Your are completely right $\endgroup$ Jan 9, 2020 at 17:40
  • $\begingroup$ I can get 10^-3 as threshold value $\endgroup$ Jan 9, 2020 at 17:43

2 Answers 2


Let's get some sample data and generate a numerical eigensystem:

iris = Keys@ExampleData[{"MachineLearning", "FisherIris"}, "Data"];
{evals, evecs} = Eigensystem@Correlation@iris;

Correlation[iris] above happens to be a $4\times 4$ matrix. You can then use e.g. Pick to extract the eigenvectors corresponding to eigenvalues with absolute value higher than your user-defined threshold using any one of the equivalent expressions below:

With[{threshold = 0.1}, {
  Pick[evecs, evals, _?(Abs[#] > threshold &)],
  Pick[evecs, Thread[Abs[evals] > threshold]],
  Pick[evecs, UnitStep[Abs[evals] - threshold], 1]

Note also that, if your results are numerical, Eigensystem is guaranteed to return eigenvalues ordered in decreasing absolute value, and the corresponding normalized eigenvectors in the same order as the eigenvalues to which they correspond (see Details section). Since you seem to imply that your results are numerical, there should be no need for further ordering of the results.

x = Random`Private`PositionsOf[UnitStep[Abs[eivals] - threshold], 0]
  • $\begingroup$ Thanx, but how I determine threshold? it is not known. $\endgroup$ Jan 9, 2020 at 17:02
  • $\begingroup$ I supposed you would consider eigenvalues of magnitude less than a certain threshold as unimportant. So you have to know the size of threshold, not me. $\endgroup$ Jan 9, 2020 at 17:18
  • $\begingroup$ Yes. You are right $\endgroup$ Jan 9, 2020 at 17:39
  • $\begingroup$ So sorry for unconsidering $\endgroup$ Jan 9, 2020 at 17:40
  • $\begingroup$ I can get 10^-3 as threshold value. But I could not understand the mean of RandomPrivatePositionsOf. Please let see for example I have UnitStep[{1, 2, 3, 10^-3, 10^-4} - 10^-3] which results in {1, 1, 1, 1, 0}. After that I must know how many 1 is in the last list for determining x!! it is correct? $\endgroup$ Jan 9, 2020 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.