function [ mu, var ] = ellipse_distance_stats ( n, a, b )

%*****************************************************************************80
%
%% ellipse_distance_stats estimates ellipse distance statistics.
%
%  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.
%
%  Output:
%
%    real MU, VAR, the estimated mean and variance of the
%    distance between two random points on the ellipse.
%
  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 );

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

  return
end
