function M = rand3sphere(n) M(:,3) = 2.0*rand(n,1) - 1.0; t = 2.0* pi * rand(n,1); w = sqrt ( 1.0 - ( M(:,3).* M(:,3))); M(:,1) = w .* cos (t); M(:,2) = w .* sin (t);