function ball_distance_histogram ( n )

%*****************************************************************************80
%
%% ball_distance_histogram() histograms ball distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 September 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
  t = zeros ( n, 1 );
  for i = 1 : n
    p = ball_unit_sample ( );
    q = ball_unit_sample ( );
    t(i) = norm ( p - q );
  end
  tmin = 0.0
  tmax = 2.0

  bin_num = 20;
  h = ( tmax - tmin ) / bin_num
  bins = linspace ( tmin + h, tmax - h, bin_num );
  normalization = bin_num / 2.0;
  hist ( t, bins, normalization );
  grid ( 'on' )
  xlabel ( '<-- Distance -->' )
  ylabel ( '<-- Frequency -->' )
  title ( 'Distance between a pair of random points in a unit ball' )

  return
end
