1%{ @file dtmc_makestochastic.m
2 % @brief Normalizes a matrix to be a valid stochastic matrix
4 % @author LINE Development Team
8 % @brief Normalizes a matrix to be a valid stochastic matrix
11 % Rescales rows to sum to 1. Rows with zero sum are set to have 1 at the diagonal.
15 %
P = dtmc_makestochastic(
P)
20 % <tr><th>Name<th>Description
21 % <tr><td>
P<td>Input matrix
26 % <tr><th>Name<th>Description
27 % <tr><td>
P<td>Valid stochastic transition matrix
30function
P=dtmc_makestochastic(
P)
33 P(i,:)=
P(i,:)/sum(
P(i,:));
34 P(i,i)=min(max(0,1-(sum(
P(i,:))-
P(i,i))),1);