function x = sphere01_sample ( n )

%*****************************************************************************80
%
%% sphere01_sample() maps uniform points onto the unit sphere.
%
%  Discussion:
%
%    The sphere has center 0 and radius 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    26 September 2010
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Russell Cheng,
%    Random Variate Generation,
%    in Handbook of Simulation,
%    edited by Jerry Banks,
%    Wiley, 1998, pages 168.
%
%    Reuven Rubinstein,
%    Monte Carlo Optimization, Simulation, and Sensitivity 
%    of Queueing Networks,
%    Krieger, 1992,
%    ISBN: 0894647644,
%    LC: QA298.R79.
%
%  Input:
%
%    integer N, the number of points.
%
%  Output:
%
%    real X(3,N), the points.
%
% rng ( 'shuffle' );

  x = randn ( 3, n );
  norm = ones ( 1, 3 ) * ( x.^2 );
  norm = sqrt ( norm );
  for i = 1 : 3
    x(i,1:n) = x(i,1:n) ./ norm(1:n);
  end

  return
end
