function hyperball_distance_pdf ( m )

%*****************************************************************************80
%
%% hyperball_distance_pdf plots the PDF for the hyperball distance problem.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 September 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
  d = linspace ( 0.0, 2.0, 101 );

  dh = d / 2;
  pdf = 0.5 * 2^m * m * dh.^(m-1) .* betainc ( 1.0 - dh.^2, ( m + 1 ) / 2, 1 / 2 );

  plot ( d, pdf, 'r-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Probability -->' );
  title ( 'PDF for pairwise distance of random unit hyperball points' );

  return
end

