function hypercube_surface_distance_histogram ( n, d )

%*****************************************************************************80
%
%% hypercube_surface_distance_histogram histograms hypercube surface distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
%    integer D, the spatial dimension.
%
  p1 = hypercube_surface_sample ( n, d );
  p2 = hypercube_surface_sample ( n, d );
  t = vecnorm ( ( p1 - p2 )' );

  bins = 40;
  histogram ( t, bins, 'Binlimits', [0.0,sqrt(d)], 'Normalization', 'pdf' );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  title_string = sprintf ( ...
    'Distance between random points on %d-dimensional hypercube surface', d );
  title ( title_string );
  return
end
 
