Here, we sketch out the objective function and gradient used to find the maximum likelihood reversible count matrix.
Let \(C_{ij}\) be the matrix of observed counts. \(C\) must be strongly connected for this approach to work! Below, \(f\) is the log likelihood of the observed counts.
Let \(T_{ij} = \frac{X_{ij}}{\sum_j X_{ij}}\), \(X_{ij} = \exp(u_{ij})\), \(q_i = \sum_j \exp(u_{ij})\)
Here, \(u_{ij}\) is the log-space representation of \(X_{ij}\). It follows that \(T_{ij} = \exp(u_{ij}) \frac{1}{q_i}\), so \(\log(T_{ij}) = u_{ij} - \log(q_{i})\)
Let \(N_i = \sum_j C_{ij}\)
Let \(u_{ij} = u_{ji}\) for \(i > j\), eliminating terms with \(i>j\).
Let \(S_{ij} = C_{ij} + C_{ji}\)
Let \(v_i = \frac{N_i}{q_i}\)
Thus,