function paradox ( a )

%*****************************************************************************80
%
%% PARADOX looks at the average lifetime of a complex system.
%
%  Discussion:
%
%    A simple system has an average lifetime of A.
%    For reliability, a complex system is constructed of three simple systems.
%    The complex system will only fail if at least two of the simple systems fail.
%    What is the average lifetime of the complex system?
%
%  Modified:
%
%    30 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Dueling Idiots and Other Probability Puzzlers,
%    Princeton, 2012,
%    ISBN: 978-0691155005.
%
%  Parameters:
%
%    Input, real A, the average lifetime of a single system.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PARADOX:\n' );
  fprintf ( 1, '  A simple system has an average lifetime of A.\n' );
  fprintf ( 1, '  For reliability, a complex system is constructed of three simple systems.\n' );
  fprintf ( 1, '  The complex system will only fail if at least two of the simple systems fail.\n' );
  fprintf ( 1, '  What is the average lifetime of the complex system?\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Present the results graphically.\n' );

  a = 1 / a;

  for n = 1 : 200
    s(n) = 1 - exp ( - a * n );
    r(n) = s(n) * s(n) * ( 3 - 2 * s(n) );
  end
%
%  Graphics.
%
  clf
  grid
  t = 1 : 200;
  plot(t,s,'-',t,r,'.')
  ylabel('probability of failure by time t')
  xlabel('time t, in arbitrary units')
  grid
  title('Fig.20.1 - Average Lifetime of a system is 100')
  legend('system','SYSTEM')
  print ( '-dpng', 'paradox.png' )

  return
end
