Problem
This is a example from textbook. However, I get the different answer.
Example:
For a teleportation rate of 0.14 its (stochastic) transition probability matrix is below. The pagerank vector of this matrix is
> P = [0.05 0.04 0.11 0.25 0.21 0.04 0.31].
Transition probability matrix
A =
0.0200 0.0200 0.8800 0.0200 0.0200 0.0200 0.0200
0.0200 0.4500 0.4500 0.0200 0.0200 0.0200 0.0200
0.3100 0.0200 0.3100 0.3100 0.0200 0.0200 0.0200
0.0200 0.0200 0.0200 0.4500 0.4500 0.0200 0.0200
0.0200 0.0200 0.0200 0.0200 0.0200 0.0200 0.8800
0.0200 0.0200 0.0200 0.0200 0.0200 0.4500 0.4500
0.0200 0.0200 0.0200 0.3100 0.3100 0.0200 0.3100
My try
I used MATLAB to solve this problem. The true matrix with teleport is
> A' = A * (1 - 0.14) + 0.14 * 1 / 7
Then I try to calculate the eigenvector.
> [V,D] = eig(A')
And the the eigenvector with eigenvalue=1 will be the answer. However, I got
> [0.1751 0.1377 0.3550 0.5137 0.4255 0.1377 0.6005].
What am I doing wrong? Here is the corresponding MATLAB output:
>> A' =
0.0372 0.0372 0.7768 0.0372 0.0372 0.0372 0.0372
0.0372 0.4070 0.4070 0.0372 0.0372 0.0372 0.0372
0.2866 0.0372 0.2866 0.2866 0.0372 0.0372 0.0372
0.0372 0.0372 0.0372 0.4070 0.4070 0.0372 0.0372
0.0372 0.0372 0.0372 0.0372 0.0372 0.0372 0.7768
0.0372 0.0372 0.0372 0.0372 0.0372 0.4070 0.4070
0.0372 0.0372 0.0372 0.2866 0.2866 0.0372 0.2866
>> [V,D] = eig(A')
V =
0.1751 0.4326 -0.0005 -0.0003 0.2826 0.2820 0.3396
0.1377 -0.0000 0.0005 0.0007 0.0000 -0.4279 -0.5152
0.3550 -0.5594 0.0012 0.0010 0.6482 0.4182 0.5035
0.5137 -0.0000 -0.4121 -0.5374 -0.0000 0.4279 0.3142
0.4255 -0.4326 -0.4097 -0.2704 -0.2826 0.1459 -0.0253
0.1377 0.0000 0.0005 0.0007 0.0000 -0.4279 -0.1132
0.6005 0.5594 0.8139 0.7988 -0.6482 -0.4182 -0.5035
D =
1.0035 0 0 0 0 0 0
0 -0.3225 0 0 0 0 0
0 0 -0.1229 0 0 0 0
0 0 0 -0.0010 0 0 0
0 0 0 0 0.5719 0 0
0 0 0 0 0 0.3698 0
0 0 0 0 0 0 0.3698
>> V'
ans =
0.1751 0.1377 0.3550 0.5137 0.4255 0.1377 0.6005
0.4326 -0.0000 -0.5594 -0.0000 -0.4326 0.0000 0.5594
-0.0005 0.0005 0.0012 -0.4121 -0.4097 0.0005 0.8139
-0.0003 0.0007 0.0010 -0.5374 -0.2704 0.0007 0.7988
0.2826 0.0000 0.6482 -0.0000 -0.2826 0.0000 -0.6482
0.2820 -0.4279 0.4182 0.4279 0.1459 -0.4279 -0.4182
0.3396 -0.5152 0.5035 0.3142 -0.0253 -0.1132 -0.5035
One thing is that the rows of your transition matrix should sum to 1 so that it's a proper stochastic matrix (they're slightly off). When you calculate the stationary distribution, you take the eigenvector whose eigenvalue is 1. That's correct, but you have to normalize it to have sum one, so that it's a proper probability distribution. If you do that, you'll see that the stationary distribution (of the matrix A
that you listed, after normalizing rows to unit sum) is basically equal to your stated 'correct' value of [0.05 0.04 0.11 0.25 0.21 0.04 0.31]
. From your description, it sounds like A
already contains the teleportation transitions, so it's not necessary in your code to run A = A * (1 - 0.14) + 0.14 * 1 / 7
. That accounts for why the stationary distribution of A
already matches the 'correct' answer.