function ISI = calculate_ISI(W,A)

p = W*A;
p = abs(p);

N = size(p,1);

b1 = 0;
for i = 1:N
    a1 = 0;
    max_pij = max(p(i,:));
    for j = 1:N
        
        pij = p(i,j);
        a1 = pij/max_pij + a1;
    end
    b1 = a1 - 1 + b1;
end 

b2 = 0;
for j = 1:N
    a2 = 0;
    max_pij = max(p(:,j));
    for i = 1:N
        
        pij = p(i,j);
        a2 = pij/max_pij + a2;
    end
    b2 = a2 - 1 + b2;
end 

ISI = (b1+b2)/((N-1)*N*2);

end