% compute normalized markov matrix
% 8x8 for test
clear all
clc

s = 0.75 ; % the ratio of one element to the next in a row

A = [ 1 s s^2 s^3 s^4 s^5 s^6 s^7; 
      s 1 s s^2 s^3 s^4 s^5 s^6 ;
      s^2 s 1 s s^2 s^3 s^4 s^5 ;
      s^3 s^2 s 1 s s^2 s^3 s^4 ;
      s^4 s^3 s^2 s 1 s s^2 s^3 ;
      s^5 s^4 s^3 s^2 s 1 s s^2 ;
      s^6 s^5 s^4 s^3 s^2 s 1 s ;
      s^7 s^6 s^5 s^4 s^3 s^2 s 1 ;] ;
  
for i=1:8
    norm = 127/sum(A(i,:));
    Anorm(i,:) = A(i,:)*norm ;
end

Anorm = round(Anorm);

for i=1:8
   d = sum(Anorm(i,:)) - 127 ;
   Anorm(i,i) = Anorm(i,i) - d ;
   fprintf('%d,%d,%d,%d,%d,%d,%d,%d,\n', Anorm(i,:))
end

 

% for i=1:8
%   sum(Anorm(i,:)) 
% end