I experimented with the PageRank algorithm. When the number of pages is large, I encountered a situation when one formula for re-normalizing a vector (so that sum of its components is equal to 1; elements of the vector are guaranteed to be positive) works fine, while another stops working and using it causes that the iterations start to diverge (difference between old and new r starts growing bigger) after a while.
r = r./sum(r) # this does not work
r = r + (1-sum(r))/N * ones(N) # this works
My PageRank algorighm looks like this (Julia)
M # M is NxN sparse transition matrix;
# may contain all-zero columns (sinks);
beta = 0.8
epsilon = 1e-6
r = 1/N ./ ones(N)
rtm1 = ones(N)
while(sum(abs(r-rtm1)) > epsilon)
rtm1 = r
r = beta*M*r
######
# renormalization
# pick one or the other
# r = r./sum(r)
# r = r + (1-sum(r))/N * ones(N)
######
end
# now r holds the result
I am guessing that for large number of pages the elements of r can get very small (like 1.0e-7 or smaller) and the first normalization formula then does not work very well. I would like to hear an explanation why is that from somebody who has some experience with numeric computations.