function gaussian_test ( )

%*****************************************************************************80
%
%% gaussian_test() tests gaussian().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 May 2020
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../gaussian' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'gaussian_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  gaussian() evaluates the Gaussian function and its derivatives.\n' );

  gaussian_n_test ( );
  gaussian_mu_test ( );
  gaussian_sigma_test ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gaussian_test()\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  timestamp ( );

  rmpath ( '../gaussian' );

  return
end
function gaussian_mu_test ( )

%*****************************************************************************80
%
%% gaussian_mu_test varies the mu parameter.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 December 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gaussian_mu_test\n' );
  fprintf ( 1, '  Compute gaussian(n,mu,sigma,x) for various values of mu.\n' );
  fprintf ( 1, '\n' );

  n = 0;
  sigma = 1.0;
  a = - 4.0;
  b = + 4.0;
  x = linspace ( a, b, 101 );

  clf ( );
  hold ( 'on' );

  for mu = [ -1.0, -0.5, 0.0, 0.5, 1.0 ]

    g = gaussian_value ( n, mu, sigma, x );

    plot ( x, g, 'linewidth', 3 );

  end

  grid ( 'on' );
  xlabel ( '<-- x -->' );
  if ( n == 0 )
    label = 'g(x)';
  elseif ( n == 1 )
    label = 'd g(x)/dx';
  else
    label = sprintf ( 'd^%d g(x)/dx^%d', n, n );
  end
  label = sprintf ( '<-- %s -->', label );
  ylabel ( label );

  if ( n == 0 )
    label = 'g(mu=[-1,-1/2,0,1/2,1],sigma,x)';
  elseif ( n == 1 )
    label = 'd g(mu=[-1,-1/2,0,1/2,1],sigma,x)/dx';
  else
    label = sprintf ( 'd^%d g(mu=[-1,-1/2,0,1/2,1],sigma,x)/dx^%d', n, n );
  end
  hold ( 'off' )

  title ( label );
  filename = sprintf ( 'gaussian_mu.png' );
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function gaussian_n_test ( )

%*****************************************************************************80
%
%% gaussian_n_test varies the n parameter.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 December 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gaussian_n_test\n' );
  fprintf ( 1, '  Compute gaussian(n,mu,sigma,x) for various values of n.\n' );
  fprintf ( 1, '\n' );

  mu = 0.0;
  sigma = 1.0;
  a = - 4.0;
  b = + 4.0;
  x = linspace ( a, b, 101 );

  for n = 0 : 5

    g = gaussian_value ( n, mu, sigma, x );

    plot ( x, g, 'linewidth', 3 );

    grid ( 'on' );
    xlabel ( '<-- x -->' );
    if ( n == 0 )
      label = 'g(x)';
    elseif ( n == 1 )
      label = 'd g(x)/dx';
    else
      label = sprintf ( 'd^%d g(x)/dx^%d', n, n );
    end
    label = sprintf ( '<-- %s -->', label );
    ylabel ( label );

    if ( n == 0 )
      label = 'g(mu,sigma,x)';
    elseif ( n == 1 )
      label = 'd g(mu,sigma,x)/dx';
    else
      label = sprintf ( 'd^%d g(mu,sigma,x)/dx^%d', n, n );
    end
    hold ( 'off' )

    title ( label );
    filename = sprintf ( 'gaussian_n%d.png', n );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  end

  return
end
function gaussian_sigma_test ( )

%*****************************************************************************80
%
%% gaussian_sigma_test varies the sigma parameter.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 December 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gaussian_sigma_test\n' );
  fprintf ( 1, '  Compute gaussian(n,mu,sigma,x) for various values of sigma.\n' );
  fprintf ( 1, '\n' );

  n = 0;
  mu = 0.0;
  a = - 4.0;
  b = + 4.0;
  x = linspace ( a, b, 101 );

  clf ( );
  hold ( 'on' );

  for sigma = [ 0.25, 0.50, 1.0, 1.5, 2.0 ]

    g = gaussian_value ( n, mu, sigma, x );

    plot ( x, g, 'linewidth', 3 );

  end

  grid ( 'on' );
  xlabel ( '<-- x -->' );
  if ( n == 0 )
    label = 'g(x)';
  elseif ( n == 1 )
    label = 'd g(x)/dx';
  else
    label = sprintf ( 'd^%d g(x)/dx^%d', n, n );
  end
  label = sprintf ( '<-- %s -->', label );
  ylabel ( label );

  if ( n == 0 )
    label = 'g(mu,sigma=[0.25,0.50,1,1.5,2],x)';
  elseif ( n == 1 )
    label = 'd g(mu,sigma=[0.25,0.50,1,1.5,2],x)/dx';
  else
    label = sprintf ( 'd^%d g(mu,sigma=[0.25,0.50,1,1.5,2],x)/dx^%d', n, n );
  end
  hold ( 'off' )

  title ( label );
  filename = sprintf ( 'gaussian_sigma.png' );
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

