% part_b % % Finds the limiting distribution for the Markov chain by simulating % the chain multiple times starting from 1. function lim_dist = part_b(n,number_of_simulations,time) % Input Variables % n The size of the state space % number_of_simulations Number of times to simulate chain % time Amount of time to simulate chain % Initialize frequencies = zeros(n,1); % keep track of where chain ends up for loop1 = 1:number_of_simulations x = 1; % starting state u = rand(time,1); % draw the uniform random variables we will need for loop2 = 1:time x = part_a(x,u(loop2),n); end frequencies(x) = frequencies(x) + 1; end lim_dist = frequencies / number_of_simulations;