function ellipse_distance_histogram ( n, a, b )

%*****************************************************************************80
%
%% ellipse_distance_histogram histograms ellipse distance statistics.
%
%  Discussion:
%
%    The ellipse will be assumed to have the form:
%
%      (x/a)^2 + (y/b)^2 = 1;
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 March 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
%    real A, B, the ellipse parameters.
%
  p = ellipse_sample ( n, a, b );
  q = ellipse_sample ( n, a, b );
%
%  First "2" is for the L2 norm, second "2" indicates taking norm along rows...
%
  t = vecnorm ( p - q, 2, 2 );

  tmax = max ( abs ( a ), abs ( b ) );
  bins = 20;
  histogram ( t, bins, 'Binlimits', [0.0,tmax], 'Normalization', 'pdf' );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  label = sprintf ( 'Pairwise point distances on ellipse with a = %g, b = %g\n', a, b );
  title ( label );

  return
end
