function disk_distance_pdf ( )

%*****************************************************************************80
%
%% disk_distance_pdf() plots the PDF for the disk distance problem.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    John Hammersley,
%    The distribution of distance in a hypersphere,
%    The Annals of Mathematical Statistics,
%    Volume 21, Number 3, pages 447-452, 1950.
%
  d = linspace ( 0.0, 2.0, 101 );
%
%  The PDF is typically given in terms of a normalized distance 0 <= Lambda <= 1.
%  We prefer to look at the physical distance 0 <= D <= 2.
%  To exploit the formula in its original form, we need to divide D by 2 first,
%  evaluate the PDF, and then divide that by 2.
%
  pdf = d .* ( 4.0 * acos ( d / 2.0 ) - d .* sqrt ( 4.0 - d.^2 ) ) / pi;

  plot ( d, pdf, 'r-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Probability -->' );
  title ( 'PDF for distance between pairs of random points in disk' );

  return
end

