This is the long-promised program that will generate the following
1. Runs Scored per 27 outs
2. Run Expectancy Matrix, by the 24 base/out states
3. Run Frequency Matrix, by the 24 base/out states
4. Run Values by Event (Linear Weights)
This program is mathematically perfect. In order to write such a simple program with something as complex as baseball, I had to change reality. This model does not consider the possibility of runners being out on base, nor of runners advancing in the middle of a plate appearance (SB, CS, WP, PB, BK). Because of that, some of the numbers will look slightly off. But, it provides a great baseline that you can tweak.
However, I do allow for the chance of taking the extra base to be dynamic. So, if you wanted to see the run scoring impact of being able to go 1B to 3B, with 2 outs, 40% of the time, instead of 30% of the time, you can do it. (Numbers for illustration only.)
Ever wanted to know how many runs would score if a team got on base 75% of the time? Now you'll know with mathematical precision, with the noted assumptions.
And, the source code is there for you to use. Feel free to make it more efficient, or turn it into a perl script, or change it how you like. All I ask is that you post a link back to this webpage:
http://www.tangotiger.net/markov.html
On-going discussions and updates are noted on my blog.