function q = q8_normal_01 ( )

%*****************************************************************************80
%
%% q8_normal_01() returns a normally distributed quaternion.
%
%  Discussion:
%
%    The normal distribution with mean 0 and variance 1 is used.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 July 2021
%
%  Author:
%
%    John Burkardt
%
%  Output:
%
%    real Q(4), the sampled quaternion.
%
  q = zeros ( 4, 1 );

  r = rand ( 4, 1 );

  q(1:2:3,1) = ...
    sqrt ( -2.0 * log ( r(1:2:3,1) ) ) ...
    .* cos ( 2.0 * pi * r(2:2:4,1) );

  q(2:2:4,1) = ...
    sqrt ( -2.0 * log ( r(1:2:3,1) ) ) ...
    .* sin ( 2.0 * pi * r(2:2:4,1) );

  return
end
