function value = genf ( dfn, dfd )

%*****************************************************************************80
%
%% GENF generates an F random deviate.
%
%  Discussion:
%
%    This procedure generates a random deviate from the F (variance ratio)
%    distribution with DFN degrees of freedom in the numerator
%    and DFD degrees of freedom in the denominator.
%
%    It directly generates the ratio of chisquare variates
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    31 March 2013
%
%  Author:
%
%    Original FORTRAN77 version by Barry Brown, James Lovato.
%    MATLAB version by John Burkardt.
%
%  Parameters:
%
%    Input, real DFN, the numerator degrees of freedom.
%    0.0 < DFN.
%
%    Input, real DFD, the denominator degrees of freedom.
%    0.0 < DFD.
%
%    Output, real VALUE, a random deviate from the distribution.
%
  if ( dfn <= 0.0 )
    fprintf ( 1, ' \n' );
    fprintf ( 1, 'GENF - Fatal error!\n' );
    fprintf ( 1, '  DFN <= 0.0\n' );
    error ( 'GENF - Fatal error!\n' );
  end

  if ( dfd <= 0.0 )
    fprintf ( 1, ' \n' );
    fprintf ( 1, 'GENF - Fatal error!\n' );
    fprintf ( 1, '  DFD <= 0.0\n' );
    error ( 'GENF - Fatal error!\n' );
  end

  xnum = genchi ( dfn ) / dfn;
  xden = genchi ( dfd ) / dfd;
  value = xnum / xden;

  return
end
