function square_surface_distance_histogram ( n )

%*****************************************************************************80
%
%% square_surface_distance_histogram() histograms square surface distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
  p1 = square_surface_sample ( n );
  p2 = square_surface_sample ( n );

  t = zeros ( n, 1 );
  for i = 1 : n
    t(i) = norm ( p1(i,:) - p2(i,:) );
  end

  bins = 40;
  hist ( t, bins );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  title ( 'Distance between random points on unit square surface' );

  return
end
