:

## Maple Baseball

Maple
Early this season, after the Maplesoft team came out on the wrong side of a 13-6 loss, we were frustrated by the team's inability to score more runs. The previous year we averaged 14 runs a game. This started me wondering, just how many runs can our team expect with a given lineup? Suppose you assume that it takes three hits in an inning to start scoring runs. Now, let's assume you have five .500 hitters coming up to bat. What is the probability that you'll get 3 hits among those five batters, thus scoring one run? It turns out that all hitters having equal .500 averages, the probability of 3 hits in 5 at-bats is 50%. A fourth hit in six at-bats means probably one or two more runs. For a string of six .500 hitters, there's a 34% chance that they'll get 4 hits, and maybe score 3 runs. What happens if we're talking about .600 hitters? The probability of getting 3 hits in 5 at-bats jumps to 68.3%. And 4 hits in 6 at-bats is 54.4%. Ok, let's use the numbers from the game in question. The first 5 batters were batting .500, .621, .656, .528, and .595 respectively. This translates into a 65% chance of scoring 1 run. Not bad. Factor in the #6 hitter at .111, and we have a 34% chance of getting that extra hit making a multi-run rally. We had 12 players in the batting order, so let's look at the numbers for the bottom half of the order: .438, .222, .462, .455, .381, .286. We're looking at a 30% chance of scoring 1 run, and 14% chance of scoring more. Since the bottom of the order usually comes up roughly 3 times per game, we can expect 1 run out of that half. From the top of the order, we can expect to score in 2 or 3 out of four times, one of which will lead to multiple runs. The total of 6 runs is therefore not unreasonable given the above model. Here's a proc that will tell you the probabilities. Input is a list of averages. For N averages, it will compute the odds of N-2 players getting hits.
```stat := proc( T )
local N, p1, p2, i, s, n, H, P, pr;
N := nops(T);
p1 := 0; p2 := 0;
for i from 0 to 2^N-1 do
s := sprintf("%0*d",N,convert(i,binary));
for n from 1 to N do
H[n] := op(sscanf(s[n],"%d"));
P[n] := `if`(H[n] = 0, 1-T[n],T[n]);
od;
pr := mul(P[i],i=1..N);
p1 := p1 + pr;
else
p2 := p2 + pr;
fi;
od:
p1/(p1+p2);
end;

> stat([.5,.5,.5,.5,.5]);
0.5000000000
> stat([.500,.621,.656,.528,.595]);
0.6484707161
> stat([.500,.621,.656,.528,.595,.111]);
0.3398817685

```

﻿