deeptime.markov.tools.estimation.log_likelihood¶
- deeptime.markov.tools.estimation.log_likelihood(C, T)¶
Log-likelihood of the count matrix given a transition matrix.
- Parameters:
C ((M, M) ndarray or scipy.sparse matrix) – Count matrix
T ((M, M) ndarray orscipy.sparse matrix) – Transition matrix
- Returns:
logL – Log-likelihood of the count matrix
- Return type:
float
Notes
The likelihood of a set of observed transition counts \(C=(c_{ij})\) for a given matrix of transition counts \(T=(t_{ij})\) is given by
\[L(C|P)=\prod_{i=1}^{M} \left( \prod_{j=1}^{M} p_{ij}^{c_{ij}} \right) \]The log-likelihood is given by
\[l(C|P)=\sum_{i,j=1}^{M}c_{ij} \log p_{ij}. \]The likelihood describes the probability of making an observation \(C\) for a given model \(P\).
Examples
>>> import numpy as np >>> from deeptime.markov.tools.estimation import log_likelihood
>>> T = np.array([[0.9, 0.1, 0.0], [0.5, 0.0, 0.5], [0.0, 0.1, 0.9]])
>>> C = np.array([[58, 7, 0], [6, 0, 4], [0, 3, 21]]) >>> logL = log_likelihood(C, T) >>> logL -38.2808034725...
>>> C = np.array([[58, 20, 0], [6, 0, 4], [0, 3, 21]]) >>> logL = log_likelihood(C, T) >>> logL -68.2144096814...
References