function x = zipf_probability ( n, p )

%*****************************************************************************80
%
%% zipf_probability() sets up a Zipf probability vector.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    21 February 2016
%
%  Author:
%
%    Original C version by Warren Smith.
%    This version by John Burkardt.
%
%  Reference:
%
%    George Zipf,
%    The Psychobiology of Language,
%    1935.
%
%  Input:
%
%    integer N, indicates the size of X.
%
%    real P, the Zipf parameter.
%    1.0 < P.
%
%  Output:
%
%    real X(1:N+2), contains in X(2) through X(N+1) the
%    probabilities of outcomes 1 through N.
%
  x = zeros ( n + 2, 1 );

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

  x = normalize ( n, x );

  return
end

