I'm trying to calculate the probability that a point (a nxn matrix) uniformly distributed in R^(n^2) exclusively has eigenvalues with negative real part, but I keep getting the following error:
Not enough input arguments.
Error in probability_n (line 4)
for i = 1:num_pts
Here is my code:
N = 10^2;
num_pts = 10^4;
n = 2;
n = n*ones(N,1,'gpuArray');
k = arrayfun(probability_n,n,num_pts);
and the function called is
function k = probability_n(n,num_pts)
k = 0;
for i = 1:num_pts
R = reshape(randsphere(1,n^2,1),n,n);
if all(real(eig(R))<0)
k = k+1;
end
end
end
function P = randsphere(m,n,r)
P = randn(m,n);
s2 = sum(P.^2,2);
P = P.*repmat(r*(gammainc(s2/2,n/2).^(1/n))./sqrt(s2),1,n);
end
Why is this happening? I suspect it is something very simple to do with a syntax error, since this is my first time trying to use my GPU for MATLAB. The GPU is an Nvidia GeForce GTX 580. Thanks.