Starting diary file diary-18-Oct-2010.txt A = [.95 .5 ; .05 .5] sum(A) x = [.5;.5] A*x xx = x xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx xx = A* xx x =[ 1 ; 0] xx = x xx = A* xx xx = A* xx % I repeated this about 20 times; you can do it in a loop! x = [0 ; 1] xx = x xx = A* xx xx = A* xx % ... S = [ .75 .1 ; .25 .9] x = [.5;.5] xx = x xx = S*xx xx = S*xx xx = S*xx % about 20 times ... clear load harvard500 whos U size(G) spy(G) full(sum(G)) clc p = .85 c = sum(G) whos c = full(c) clc whos D = diag( 1./c) % oops, this is dense and has Inf's in it.... clc K = find(c~=0) size(K) nnz(c) [n,n] = size(G) % The next line has the bug that took us so long to find in class... % it should have been 1./c(K), not just c(K). % D = sparse( K, K, c(K), n, n); size(D) nnz(D) length(K) whos nnz(D) D e = ones(n,1) whos z = ( (c==0) + (1-p)*(c~=0) ) / n; size(z) z whos A = p * G * D + e * z; size(A) sum(A) % Here's where we noticed the problem ... the sums aren't equal to 1! clc s = sum(A); full(s) s(1) clc D % Aha! The entries of D should be less than 1, not integers. D = sparse( K, K, 1 ./ c(K), n, n); D max(max(D)) min(min(D)) A = p * G * D + e * z; full(sum(A)) s = sum(A); max(s) min(s) x = e/n; xx = x; for i=1:100,plot(xx,'.'),pause,xx = A*xx;end; sum(xx) min(xx) max(xx) help sort y = sort(xx); y = sort(xx,1,'descend'); y whos [y,p] = sort(xx,1,'descend'); p' clc U(p) diary off