<commit_before>.. currentmodule:: msmbuilder.msm

Continuous-time Markov State Model
==================================

Theory
------

Consider an `n`-state time-homogeneous Markov process, :math:`X(t)` At time
:math:`t`, the :math:`n`-vector :math:`P(t) = Pr[ X(t) = i ]` is probability that the system is in each of the :math:`n` states. These probabilities
evolve forward in time, governed by an :math:`n \times n` transition rate matrix :math:`K` 

.. math ::
    dP(t)/dt = P(t) \cdot K

The solution is

.. math ::
    P(t) = \exp(tK) \cdot P(0)

Where :math:`\exp(tK)` is the matrix exponential. Written differently, the state-to-state lag-:math:`\tau` transition probabilities are

.. math ::
    Pr[ X(t+\tau) = j \;|\; X(t) = i ] = exp(\tau K)_{ij}

For this model, we observe the evolution of one or more chains, :math:`X(t)` at
a regular interval, :math:`\tau`. Let :math:`C_{ij}` be the number of times the
chain was observed at state :math:`i` at time :math:`t` and at state :math:`j` at time :math:`t+\tau` (the number of observed transition counts). Suppose that
:math:`K` depends on a length-:math:`b` parameter vector, :math:`\theta`. The log-likelihood is

.. math ::
  \mathcal{L}(\theta) = \sum_{ij} \left[
      C_{ij} \log\left(\left[\exp(\tau K(\theta))\right]_{ij}\right)\right]

Dense Parameterization
----------------------
This code parameterizes :math:`K(\theta)` such that :math:`K` is constrained
to satisfy `detailed balance <http://en.wikipedia.org/wiki/Detailed_balance>`_
with respect to a stationary distribution, :math:`pi`. For an :math:`n`-state
model, :math:`\theta` is of length :math:`n(n-1)/2 + n`. The first
:math:`n(n-1)/2` elements of :math:`theta` are the parameterize the symmetric
rate matrix, :math:`S`, and the remaining :math:`n` entries parameterize the
stationary distribution. For :math:`n=4`, the function :math:`K(\theta)` is

.. math ::
    \begin{array}a<commit_msg>Update ratematrix.rst<commit_after>.. currentmodule:: msmbuilder.msm

Continuous-time Markov State Model
==================================

Theory
------

Consider an `n`-state time-homogeneous Markov process, :math:`X(t)` At time
:math:`t`, the :math:`n`-vector :math:`P(t) = Pr[ X(t) = i ]` is probability that the system is in each of the :math:`n` states. These probabilities
evolve forward in time, governed by an :math:`n \times n` transition rate matrix :math:`K` 

.. math ::
    dP(t)/dt = P(t) \cdot K

The solution is

.. math ::
    P(t) = \exp(tK) \cdot P(0)

Where :math:`\exp(tK)` is the matrix exponential. Written differently, the state-to-state lag-:math:`\tau` transition probabilities are

.. math ::
    Pr[ X(t+\tau) = j \;|\; X(t) = i ] = exp(\tau K)_{ij}

For this model, we observe the evolution of one or more chains, :math:`X(t)` at
a regular interval, :math:`\tau`. Let :math:`C_{ij}` be the number of times the
chain was observed at state :math:`i` at time :math:`t` and at state :math:`j` at time :math:`t+\tau` (the number of observed transition counts). Suppose that
:math:`K` depends on a length-:math:`b` parameter vector, :math:`\theta`. The log-likelihood is

.. math ::
  \mathcal{L}(\theta) = \sum_{ij} \left[
      C_{ij} \log\left(\left[\exp(\tau K(\theta))\right]_{ij}\right)\right]

Dense Parameterization
----------------------
This code parameterizes :math:`K(\theta)` such that :math:`K` is constrained
to satisfy `detailed balance <http://en.wikipedia.org/wiki/Detailed_balance>`_
with respect to a stationary distribution, :math:`\pi`. For an :math:`n`-state
model, :math:`\theta` is of length :math:`n(n-1)/2 + n`. The first
:math:`n(n-1)/2` elements of :math:`theta` are the parameterize the symmetric
rate matrix, :math:`S`, and the remaining :math:`n` entries parameterize the
stationary distribution. For :math:`n=4`, the function :math:`K(\theta)` is

.. math ::
    \begin{array}a
{'fraction_non_alphanumeric': 0.19425019425019424, 'fraction_numerical': 0.003108003108003108, 'mean_word_length': 4.054973821989528, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5856287', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1258, 'n_words': 438}