function permutation_distance_histogram ( m, n )

%*****************************************************************************80
%
%% permutation_distance_histogram() histograms permutation distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the order of the permutations.
%
%    integer N, the number of samples to use.
%
  t = zeros ( n, 1 );
  for i = 1 : n
    p1 = randperm ( m );
    p2 = randperm ( m );
    t(i) = permutation_distance_ulam ( p1, p2 );
  end

  bins = m + 1;
% histogram ( t, bins, 'Binlimits', [0,m], 'Normalization', 'pdf' );
  histogram_pdf ( t, bins );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  title_string = sprintf ( ...
    'Ulam distance between random permutations of order %d', m );
  title ( title_string );
  filename = 'permutation_distance_histogram.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
 
