function x = zipf_probability ( n, p )

%*****************************************************************************80
%
%% ZIPF_PROBABILITY sets up a Zipf probability vector.
%
%  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.
%
%  Reference:
%
%    George Zipf,
%    The Psychobiology of Language,
%    1935.
%
%  Parameters:
%
%    Input, integer N, indicates the size of X.
%
%    Input, real P, the Zipf parameter.
%    1.0 < P.
%
%    Output, real X(0:N+1), contains in X(1) through X(N) the
%    probabilities of outcomes 1 through N.
%
  x = zeros ( n + 2, 1 );

  x(0+1) = 0.0;
  for i = 1 : n
    x(i+1) = i ^ ( - p );
  end
  x(n+1+1) = 0.0;

  x = normalize ( n, x );

  return
end

