function rectangle_distance_histogram ( n, a, b )

%*****************************************************************************80
%
%% rectangle_distance_histogram() histograms rectangle distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 May 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of pairs of sample points to use.
%
%    real a, b: the length of the two sides.
%
  p = rectangle_sample ( n, a, b );
  q = rectangle_sample ( n, a, b );
  t = zeros ( n, 1 );
  for i = 1 : n
    t(i) = norm ( p(i,1:2) - q(i,1:2) );
  end

  bins = 20;
  dmin = 0.0;
  dmax = sqrt ( a^2 + b^2 );
  dx = ( dmax - dmin ) / bins;
  norm = 1.0 / dx;
  hist ( t, bins, norm );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  s = sprintf ( 'Distance two random points, rectangle %g x %g', a, b );
  title ( s );

  return
end
