function [ q, seed ] = q8_normal_01 ( seed )

%*****************************************************************************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 GNU LGPL license.
%
%  Modified:
%
%    22 July 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer SEED, a seed for the random number generator.
%
%    Output, real Q(4), the sampled quaternion.
%
%    Output, integer SEED, an updated seed for the random number generator.
%
  q = zeros ( 4, 1 );

  [ r, seed ] = r8vec_uniform_01 ( 4, seed );

  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
