% P2
% Tests MakeSingular
clc
rand('seed',0)
n = 30;
A = rand(n,n);
for k=1:n
A(:,k) = A(:,k)/sum(A(:,k));
end
thetaVals = MakeSingular(A);
clc
disp(' thetaVals(k) 1/A(k,k) A(theta,k) Stochastic?')
disp('---------------------------------------------------------------')
for k=1:n
Ak = A;
theta = thetaVals(k);
mu = (1 - theta*A(k,k))/(1 - A(k,k));
Ak(:,k) = [mu*A(1:k-1,k);theta*A(k,k);mu*A(k+1:n,k)];
sn = min(svd(Ak));
if 0<=thetaVals(k) && thetaVals(k)<=1/A(k,k)
fprintf('%20.15f %10.3f Yes %10.2e\n',thetaVals(k),1/A(k,k),sn)
else
fprintf('%20.15f %10.3f No %10.2e\n',thetaVals(k),1/A(k,k),sn)
end
end