Markov Chains in Maple

The following is a procedure for Maple that simulates a Markov chain by executing a specified number of trials: