function x = dipole_sample ( a, b )

%*****************************************************************************80
%
%% dipole_sample() samples the Dipole PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Robert Knop,
%    Algorithm 441,
%    ACM Transactions on Mathematical Software.
%
%  Input:
%
%    real A, B, the parameters of the PDF.
%    A is arbitrary, but represents an angle, so only 0 <= A <= 2 * PI
%    is interesting, and -1.0 <= B <= 1.0.
%
%  Output:
%
%    real X, a sample of the PDF.
%

%
%  Find (X1,X2) at random in a circle.
%
  a2 = b * sin ( a );
  b2 = b * cos ( a );
  c2 = 1.0;

  [ x1, x2 ] = disk_sample ( a2, b2, c2 );
%
%  The dipole variate is the ratio X1 / X2.
%
  x = x1 / x2;

  return
end
