function linear_sample ( )

%*****************************************************************************80
%
%% LINEAR_SAMPLE estimates the mean and variance of the linear PDF.
%
%  Discussion:
%
%    The linear PDF for [5,10] has mean 25/3 and variance 25/18.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    27 February 2013
%
%  Author:
%
%    John Burkardt
%

%
%  Initialize.
%
  seed = 123456789;
  rng ( seed );
%
%  Generate the data.
%
  n = 1000000;
  u = rand ( n, 1 );
  x = 5 + sqrt ( 25 * u );
%
%  Histogram the data.
%
  hist ( x, 20 );
  xlabel ( '5 <== X <== 10', 'Fontsize', 24 )
  ylabel ( 'Frequency', 'Fontsize', 24 )
  title ( '1,000,000 samples from linear PDF on [5,10]', 'Fontsize', 24 );
  print ( '-dpng', 'linear_sample.png' );
%
%  Compute the data mean and variance.
%
  mu = sum ( x(1:n)    ) / n;
  mu2 = sum ( x(1:n).^2 ) / n;
  var = mu2 - mu^2;
  fprintf ( 1, '  %12d  %12g  %12g                %12g\n', n, mu, mu2, var );

  return
end

