Given that the state of the system is the number of pints on hand after a delivery, and the largest possible state is 7 due to the 21 days discarding policy. Let l be the current state, and l'-1 as the possible state change. The demand for blood is represented by the probabilities [0.4, 0.35, 0.1, 0.15] for 0, 1, 2 and 3 pints respectively.
Here, the aim is to construct a transition matrix. A transition matrix, in this context, is a square matrix indicating the probabilities of transitioning from one state to another. In this case, each entry in the matrix (i,j) can be calculated using the demand probabilities, where i is the current state and j is the next state.
Begin with an 8x8 matrix with all entries as zero. The possible states are 0, 1, 2, ..., 7.
Now, loop over possible states for each i from 0 through 7 (inclusive). Then loop over the possible demand changes in state for each d from 0 to the length of demand probabilities. The next state j is then given by max(i + 1 - d, 0), which considers the case where the demand could be more than the blood on hand (capping j at a minimum of 0).
The probability of this transition is the associated demand probability. Add this probability to the current entry of the transition matrix at position (i, j).
Repeat this for all possible states and all possible demands. This would result in a complete transition matrix for all possible state transitions.
Finally, rows in the transition matrix are normalized to sum to 1 (because each row in a transition matrix should always sum up to exactly 1), by dividing each row by the respective sum of probabilities in that row.
Following these steps, you should have the one-step transition matrix for this Markov chain problem.