1 % Initializes the model to a random initialization point
\r
2 % Takes in the number of states in the model and the number of underlying
\r
4 function model = init_kmc(num_states, num_mcs)
\r
6 model.num_states = num_states;
\r
7 model.num_mcs = num_mcs;
\r
8 % Initialize num_mcs Markov Chains, and then initialize the priors
\r
10 model.chain(i) = init_single_mc(num_states);
\r
12 model.priors = rand(num_mcs, 1);
\r
13 model.priors = model.priors / sum(model.priors);
\r
15 function mc = init_single_mc(num_states)
\r
17 % Initialize a single Markov Chain w/ the number of states specified. The
\r
18 % initial probabilities must sum to 1, and each row in the transition
\r
19 % matrix must sum to 1.
\r
21 mc.t = rand(num_states, 1);
\r
23 % Normalize the values to 1
\r
24 mc.t = mc.t / sum(mc.t);
\r
25 % Need one extra dimension for the end state
\r
26 mc.T = rand(num_states, num_states + 1);
\r
28 % Normalize each row to 1
\r
30 mc.T(i, :) = mc.T(i, :) / sum(mc.T(i, :));
\r