Inconsistent EigenVectors on running same problem multiple times

Hi All,
In my FEM code, I run EIG or EIGS command for getting eigenvalues and eigenvectors. Strangely, it is returning different eigenvectors that are inconsistent each time for the same code and same inputs.
Any help will be appreciated.
Best regards,

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 9 日

0 投票

If I recall, a few weeks ago someone mentioned that there is a random initialization going on (might have been by at the qr level.) Try setting the random seed, trying, setting it again, see if you get the same results.

9 件のコメント

Rehan Rehan
Rehan Rehan 2016 年 1 月 9 日
Thanks. I get your point but since I am quite new to Matlab, kindly tell me how I do the random seed.
John D'Errico
John D'Errico 2016 年 1 月 9 日
eigs (and svds) use a random start by default. Qr does not need any randomness.
Rehan Rehan
Rehan Rehan 2016 年 1 月 9 日
Then what is Qr?
Rehan Rehan
Rehan Rehan 2016 年 1 月 9 日
編集済み: Rehan Rehan 2016 年 1 月 9 日
The problem is only with Eigenvectos so I have edited the original post. I am still not clear about using "Qr" or "Seed" in particular to my Finite Element Analysis work. WOuld appreciate a little explanation with example for the following case:
[A,B]=eigs(K,M,20,'sm')
Thanks
Walter Roberson
Walter Roberson 2016 年 1 月 9 日
If your K is large and sparse then QR is not an appropriate approach.
To test the effect of randomness on eigs, use
rng(12345);
[A1,B1] = eigs(KM,20,'sm');
rng(12345);
[A2,B2] = eigs(KM,20,'sm');
and see if the two outcomes are equal.
Eigenvectors are not expected to be unique, so there is no "right" eigenvector; they are just expected to be linearly independent. See http://math.stackexchange.com/questions/235396/eigenvalues-are-unique
My memory is that eigs() initializes randomly and then iterates looking for convergence. Convergence will reach the same values (to within roundoff problems), but it might do so along different paths depending on the random initialization, so the eigenvectors might differ.
Rehan Rehan
Rehan Rehan 2016 年 1 月 11 日
That's why every time I get perfectly same eigenvalues while "unpredictably" and slightly different eigenvectos for the same problem.
So does it mean that I have to build my own algorithm to do eigenvalue analysis thereby expecting same eigenvectors for same problem ?
Guillaume
Guillaume 2016 年 1 月 11 日
No, as has been said, you can fix the seed of RNG to the same number before each time you call eigs, so that the 'random' number it uses is always the same and thus, always returns the same result.
As per Walter's later comment:
rng(12345); %use any seed you want
[A1,B1] = eigs(KM,20,'sm');
rng(12345); %as long as it's always the same
[A2,B2] = eigs(KM,20,'sm');
Steven Lord
Steven Lord 2016 年 1 月 11 日
Or set the v0 option in your EIGS call to fix the starting vector. By default, it is randomly generated.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

質問済み:

2016 年 1 月 9 日

コメント済み:

2016 年 1 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by