function cube_surface_distance_histogram ( n )

%*****************************************************************************80
%
%% cube_surface_distance_histogram() histograms cube surface distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
  p1 = cube_surface_sample ( n );
  p2 = cube_surface_sample ( n );
  t = zeros ( n, 1 );
  for i = 1 : n
    t(i) = norm ( p1(i,:) - p2(i,:) );
  end

  bin_num = 40;
  [ pop, tcent ] = hist ( t, bin_num );
  hist ( t, bin_num, sum ( tcent ) );

  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  title ( 'Distance between random points on unit cube surface' );

  return
end
