function [ mu, var, moment2 ] = box_distance_stats ( n, a, b, c )

%*****************************************************************************80
%
%% box_distance_stats() estimates box distance statistics.
%
%  Discussion:
%
%    The box has sides of length a <= b <= c.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 July 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of pairs of sample points to use.
%
%    real a, b, c: the length of the sides.
%
%  Output:
%
%    real mu, var, moment2: the estimated mean, variance,
%    and second moment of the distance between two random points in the box.
%
  p = box_sample ( n, a, b, c );
  q = box_sample ( n, a, b, c );
  t = zeros ( n, 1 );
  for i = 1 : n
    t(i) = norm ( p(i,1:3) - q(i,1:3) );
  end

  mu = sum ( t(1:n) ) / n;

  if ( 1 < n )
    var = sum ( ( t(1:n) - mu ) .^ 2 ) / ( n - 1 );
  else
    var = 0.0;
  end

  moment2 = sum ( t(1:n).^2 ) / n;

  return
end
