function prcomp ( maxobs, p, mean, xcovar, answer )

%*****************************************************************************80
%
%% prcomp() prints covariance information.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 March 2013
%
%  Author:
%
%    Original FORTRAN77 version by Barry Brown, James Lovato.
%    MATLAB version by John Burkardt.
%
%  Input:
%
%    integer MAXOBS, the number of observations.
%
%    integer P, the number of variables.
%
%    real MEAN(P), the mean for each column.
%
%    real XCOVAR(P,P), the variance/covariance matrix.
%
%    real ANSWER(MAXOBS,P), the observed values.
%
  fprintf ( 1, ' \n' );
  fprintf ( 1, 'PRCOMP:\n' );
  fprintf ( 1, '  Print and compare covariance information\n' );
  fprintf ( 1, ' \n' );

  rmean = zeros ( p, 1 );
  rvar = zeros ( p, 1 );

  for j = 1 : p
    [ rmean(j), rvar(j), ~, ~ ] = stats ( answer(1,j), maxobs );
    fprintf ( 1, '  '  Variable Number %d\n', j );
    fprintf ( 1, '  Mean     %12g  Generated %12g\n', mean(j), rmean(j) );
    fprintf ( 1, '  Variance %12g  Generated %12g\n', xcovar(j,j), rvar(j) );
  end

  fprintf ( 1, ' \n' );
  fprintf ( 1, '  Covariances:\n' );
  fprintf ( 1, ' \n' );

  for i = 1 : p
    for j = 1 : i - 1
      fprintf ( 1, '  I = %d, J = %d\n', i, j );
      rcovar(i,j) = covar ( answer(1,i), answer(1,j), maxobs );
      fprintf ( 1, '  Covariance %12g  Generated %12g\n', ...
        xcovar(i,j), rcovar(i,j) );
    end
  end

  return
end
