Skip to main content

Posts

Showing posts with the label best of seven series

Best of Seven Series

Mathematician Rob Bradley posted that the expected length of a best-of-seven series should be about 5 3/4 games, on which basis he expected the New York Yankees to win. Or maybe living close to New York has warped his sense of reality. As a programmer, I felt a compulsion to verify his claim. I could figure out a formula, or list the possibilities (70 possible ways to win or lose 4 games out of 7), but I decided to write a simulation, using the Perl programming language. This explanation may be overly-detailed for programmers, but I want facebook friends with limited programming experience to understand. sub count_games_in_series { my ( $max ) = @_; $max //= 7; my ( $won, $lost) = (0, 0); for my $games ( 1..7) { if ( int rand 2 ) { $won++; } else { $lost++; } say "won $won; lost $lost; total $games" if $VERBOSE>1; return $games if $won == 4 || $lost == 4;