Markov Assignment
1) Consider the following Markov model of a batter based
on Gray, 2002.
a)
b) Let Txy be the temporal swing error for pitch y when
expecting pitch x. For example,
Tfs is the error when a slow pitch is thrown and a fast pitch is expected. Tff, Tsf, and Tss are defined likewise.
2) Modify the function markov_at_the_bat.
a) Implement the analytic equations of the expected
temporal swing error for all possible three pitch sequences: FFF, FFS, FSF,
FSS, SFF, SFS, SSF, SSS.
i) These equations should be in general terms of as, af,
Tff, Tfs, Tsf, Tss, the probability of expecting a fast pitch on the first
pitch, and the probability of a fast pitch (not all of these terms may be needed).
ii) Assume that the batter has a .65 probability of
expecting a fast pitch on the first pitch.
iii) Assume that the probability of a fast pitch is always
.55.
iv) Assume that [af as Tff Tfs Tsf Tss] = [.7 .5 10 60 40
20].
b) Fill in the code that simulates a three-pitch
sequence.
i) Start with the same assumptions as in 2.a.
ii) What you do here is to
(1) Assume that the batter starts in some state selected
probabilistically.
(2) Simulate a pitch, again selected probabilistically
(3) Calculate swing error from the parameters (for
simplicity, assume a fixed error, e.g., Tff is a constant).
(4) Change states as necessary, probabilistically.
(5) Repeat for a total of 3 pitches.
(6) Repeat the simulation 1000 times.
(7) Calculate the average swing error and the standard
deviation of the swing errors over all simulations.
3) Hand in
a) The analytic and simulated plots.
b) The numbers returned from markov_at_the_bat.
c) The equation for part 2.a. for FSF. (Code not necessary.)