thank you,
D
thanks again,
D
Something like this perhaps:
[V,D]=eig(myMatrix);
[trash,idx]=max(abs(diag(D)));
PerronVector=V(:,idx);
Not quite, first we have to note that using max(diag(D)) is correct. But even with that change, I don't believe there is any warranty the above would return Perron vector.
For example let
Q=[0 1 0 0;
1 0 0 0;
0 0 0 1;
0 0 1 0];
We have
V1 = [1; 1; 0; 0]
V2 = [0; 0; 1; 1]
are eigen vectors corresponding to rho(Q)=1, and both are Perron vectors. However there is no thing to prevent Matlab to return
V1 = [1; 1; -1; -1]
V2 = [2; 2; -1; -1]
for example. Both of course are not Perron's vector. That's where the difficulty arises.
Bruno
[V D]=eig(M);
lambda = diag(D);
rho = max(lambda);
tol = 1e-10; % use some small tolerance
ind = find(lambda>=rho*(1-tol));
V = V(:,ind);
% Use linear programming to find a combination of V that
% has non-negative elements
% Vperron := V*x
% Vperron >= 0 <=> -V*x w= 0
% sum(V*x) = 1 <=> sum(V,1)*x = 1
A = -V;
b = zeros(size(V,1),1);
Aeq = sum(V,1);
beq = 1;
dummy = ones(size(V,2),1);
x = linprog(dummy, A, b, Aeq, beq);
Vperron = V*x
% Bruno
thank you for responding.
I would like to add that I only need the vector corresponding to the largest (absolute) eigenvalue, therefore I would rather not compute all eigenvalues+eigenvectors. I'm dealing with quite large, somewhat sparse, matrices (~700x700).
D
Do you have an example where
[V D]=eigs(A,1,'lm')
fails?
Bruno
hi Bruno, just saw your suggestion now.
it actually had no problem with the size of the matrix, and was even faster then another code I found:
http://www.mathworks.de/matlabcentral/fileexchange/22763-perron-root-computation
the two methods gave similar results, which I think is a good sign.
thank you very much
D
>
> hi Bruno, just saw your suggestion now.
> it actually had no problem with the size of the matrix, and was even faster then another code I found:
> http://www.mathworks.de/matlabcentral/fileexchange/22763-perron-root-computation
>
> the two methods gave similar results, which I think is a good sign.
> thank you very much
It looks like this code is from people who know about this kind of problem, so you should perhaps use their.
Bruno