%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stability.m
clear all
close all
clc
nlist=[4 7 10]; %the different values of n that G&A used
for loop=1:3
n=nlist(loop); % Size of matrices
reps=100000; % No. of repeats
Nmax=n^2-n; % Max number of non-zero elements
Count=zeros(Nmax,1); % Counts occurrence of stability
List=[1:n^2]'; % Labels of all elements in the matrix
List(1:n+1:end)=[]; % Labels, excluding those of diagonal elements
L=length(List); % Should equal n^2-n
for j=1:Nmax % No. of nonzero elements off-diagonal
for r=1:reps
M=zeros(n); % Initialise the matrix
ScrambledList=List(randperm(L)
Connect=ScrambledList(1:j); % Non zero elements
M(Connect)=2*rand(size(
M=M-diag(diag(0.1+0.9*rand(n))
Count(j)=Count(j)+(max(real(
end
end
hold on
plot([1:Nmax]/(n^2-n),Count/
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GA10=zeros(1,1000); %draw by hand the
n=10 line from G&A, use GA10[ ...]
GA10(1:125)=1;
%initialise matrix, then insert points to fit their graph by eye
GA10(121:130)=[0.995 0.99 0.985 0.98 0.975 0.96 0.94 0.92 0.80 0.5];
GA10(131:139)=[0.3 0.08 0.06 0.04 0.025 0.02 0.015 0.01 0.005];
plot([1:1000]/1000,GA10)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GA7=zeros(1,100); %draw by hand the
n=7 line from G&A, use GA7[...]
GA7(1:10)=[1 1 1 1 1 1 1 1 1 1];
GA7(11:20)=[1 1 1 0.99 0.98 0.97 0.96 0.95 0.92 0.9];
GA7(21:30)=[0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 0.45 0.4];
GA7(31:40)=[0.35 0.3 0.25 0.2 0.15 0.10 0.06 0.03 0.015 0.01];
GA7(41:45)=[0.008 0.006 0.004 0.002 0.001];
plot([1:100]/100,GA7)
xlabel('C')
ylabel('Probability stable')
axis([0,1,0,1])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%