function underdog1 ( )

%*****************************************************************************80
%
%% UNDERDOG1 estimates the chances of an underdog winning the World Series.
%
%  Discussion:
%
%    The World Series of Baseball involves up to 7 games between two teams.
%    Suppose the stronger team has probability P of winning any one game.
%    What is the probability that the weaker team will actually win the series?
%
%  Modified:
%
%    28 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Dueling Idiots and Other Probability Puzzlers,
%    Princeton, 2012,
%    ISBN: 978-0691155005.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'UNDERDOG1\n' );
  fprintf ( 1, '  The World Series of Baseball involves up to 7 games between two teams.\n' );
  fprintf ( 1, '  Suppose the stronger team has probability P of winning any one game.\n' );
  fprintf ( 1, '  What is the probability that the weaker team will actually win the series?\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Report the results graphically.\n' );

  for p1 = 50 : 100
    p = p1 / 100;
    common = ( 1 - p ) ^ 4;
    weaker = common * ( 1 + 4 * p + 10 * p * p + 20 * p * p * p);
    P(p1-49) = weaker;
  end
%
%  Graphics.
%
  clf
  p = .5 : .01 : 1;
  plot ( p, P )
  grid
  xlabel('probability, p, of stronger team winning an individual game')
  ylabel('probability weaker team wins the World Series')
  title('Fig.4.1-The Stronger Team Does NOT Always Win!')
  print ( '-dpng', 'underdog1.png' )

  return
end
