function x = normalize ( n, x )

%*****************************************************************************80
%
%% NORMALIZE scales a vector X so its entries sum to 1.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    21 February 2016
%
%  Author:
%
%    Original C version by Warren Smith.
%    This MATLAB version by John Burkardt.
%
%  Parameters:
%
%    Input, integer N, indicates the size of X.
%
%    Input/output, real X(0:N+1), the vector to be normalized.
%    Entries X(1) through X(N) will sum to 1 on output.
%
  s = sum ( abs ( x(2:n+1) ) );
  x(2:n+1) = x(2:n+1) / s;

  return
end

