Sorting eigenvectors using symbolic toolbox for PageRank algorithm
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Fredrik Scheie
il 5 Mag 2022
Risposto: Christine Tobler
il 5 Mag 2022
I wondering how I can sort the eigenvectors when I am using "d" as a symbolic from the symbolic toolbox? I tried using [U,D]= eig(vpa(M)), but that didn't work. Do I perhaps have to decide how the symbolic roots are sorted when solving for the eigenvectors? I am not quite sure how to do this in Matlab.
The code is given below where I have written a function and what I have in the script separately.
function [Vs] = pagerank_function(linkMatrix,d)
n = size(linkMatrix,1)
M = d * linkMatrix + (1-d)/n * ones(n)
% diagonal matrix eigenvalues D, eigenvectors mtx U
%[U,D]= eig(vpa(M))
[U,D] = eig((M))
[d,ind] = sort(diag(D))
Ds = D(ind,ind)
Vs = V(:,ind)
end
Which takes the following matrix
L2 = [0 1/2 1/3 0 0 0 0;
1/3 0 0 0 1/2 0 0;
1/3 1/2 0 1 0 0 0;
1/3 0 1/3 0 1/2 0 0;
0 0 0 0 0 0 0;
0 0 1/3 0 0 1 0;
0 0 0 0 0 0 1];
d = sym('d');
[Vs] = pagerank_function(L2,d);
The general goal I want to achieve is to study how the damping factor 'd' influences all the eigenvectors produced in 'pagerank_function'. Any help would be appreciated as I am quite new to matlab.
0 Commenti
Risposta accettata
Christine Tobler
il 5 Mag 2022
There's an unknown variable in the value you pass to sort, so this won't be sorted by magnitude as the magnitude isn't known.
Here's a small example:
syms a b c d
sort([b c a])
So the sort function for arrays of symbolic variables is sorting them lexicographically, not based on value.
That gets us to the key issue with symbolically finding the largest eigenvalue of a matrix: If you have a formula for each of the eigenvalues of a matrix, depending on parameter d, then which of these eigenvalues is largest will depend on that parameter.
For example:
eigvals = eig([d d; 2 -d])
dvec = -10:10;
plot(dvec, subs(eigvals, dvec))
So depending on your choice of d, the first or the second of the formulas for the eigenvalue could the the larger one.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Linear Algebra in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!