
% This function makes a multinomial distributions from the given
% probabilites that are passed in as a paramter 'n' and then randomly
% selects one from the given distribution - i.e., n = y = [0.2, 0.3, 0.5],
% where each elements in the vector are associated with the given states,
% e.g., {s1, s3, s7} respectively from the DTMC model used in the running
% example. 

function state = exe_State(n)

pd = makedist('Multinomial','Probabilities',n);
state = random(pd,1,1);