function cube_distance_histogram ( n )

%*****************************************************************************80
%
%% cube_distance_histogram histograms cube distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 December 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of samples to use.
%
  t = zeros ( n, 1 );

  for i = 1 : n
    p = cube_unit_sample ( );
    q = cube_unit_sample ( );
    t(i) = norm ( p - q );
  end

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

  return
end
