function x = chi_square_noncentral_sample ( a, b )

%*****************************************************************************80
%
%% chi_square_noncentral_sample() samples the noncentral Chi squared PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 September 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A, the parameter of the PDF.
%    1.0 <= A.
%
%    real B, the noncentrality parameter of the PDF.
%    0.0 <= B.
%
%  Output:
%
%    real X, a sample of the PDF.
%
  a1 = a - 1.0;

  x1 = chi_square_sample ( a1 );

  a2 = sqrt ( b );
  b2 = 1.0;
  x2 = normal_sample ( a2, b2 );

  x = x1 + x2 * x2;

  return
end
