function square_distance_histogram ( n )

%*****************************************************************************80
%
%% SQUARE_DISTANCE_HISTOGRAM histograms square distance statistics.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 October 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the number of samples to use.
%
  for i = 1 : n
    p = square_unit_sample ( );
    q = square_unit_sample ( );
    t(i) = norm ( p - q );
  end

  bins = 20;
  histogram ( t, bins, 'Binlimits', [0.0,sqrt(2.0)], 'Normalization', 'pdf' );
  grid on
  xlabel ( '<-- Distance -->' )
  ylabel ( '<-- Frequency -->' )
  title ( 'Distance between a pair of random points in a unit square' )

  return
end
