Computing PageRank

84 Views Asked by At

I'm following the book here to compute PageRank scores: http://nlp.stanford.edu/IR-book/html/htmledition/markov-chains-1.html

I built the transition matrix P as indicated in the book. Then I computed the PageRank scores by raising the transition matrix P to higher powers, as said in the book. To make sure my computations are correct I followed this example: http://nlp.stanford.edu/IR-book/html/htmledition/the-pagerank-computation-1.html

The transition matrix is: P = np.array([ [1./6, 2./3, 1./6], [5./12, 1./6, 5./12], [1./6, 2./3, 1./6] ])

The results of the PageRank scores are the following (by computing P^40):

[0.28, 0.44, 0.28]

as in the book.

But the book also says that one can find the PageRank scores by computing the principal left eigenvector of the transition matrix P. So I tried this with numpy:

v, V = np.linalg.eig(P.T)
left_vec = V[:, 0].T
print left_vec

and I got:

[-0.46829291 -0.74926865 -0.46829291]

so what's wrong?!