<commit_before>パラメータ推定
=================

0. カルマンフィルタの尤度関数
-------------------------------

完全データX,Zが

:math:`l(\theta) = \ln p(X,Z|\theta) = \ln p(z_{0}|\mu_{0},P_{0})+ \sum_{n=2}^{N} \ln p(z_{n}|z_{n-1},F,Q)+ \sum_{n=1}^{N} \ln p(x_{n}|z_{n},H,R)`

:math:`\ln \mathcal{N} (\mathbf{x}|\mathbf{\mu},\mathbf{\Sigma}) = - \frac{D\ln(2 \pi)}{2}  -\frac{1}{2} \ln(|\Sigma|) -\frac{1}{2}(\mathbf{x}- \mathbf{\mu}) \Sigma^{-1}(\mathbf{x}- \mathbf{\mu})`


1. EMアルゴリズムを用いて求める
--------------------------------

パラメータ :math:`\theta = \lbrace A , \Gamma , C , \Sigma , \mu_{0} , P_{0} \rbrace` をEMアルゴリズムによって求める


* 完全データの対数尤度関数

  :math:`\ln p(\mathbf{X},\mathbf{Z}|\theta) = \ln(z_{1}|\mu_{0},P_{0}) + \sum_{n=2}^N \ln p(z_{n}|z_{n-1},A,\Gamma) + \sum_{n=1}^{N} \ln p(x_{n}|z_{n},C,\Sigma)`

* 完全データの尤度関数の期待値

  :math:`Q(\theta,\theta^{old})=E_{\mathbf{Z}|\theta^{old}}[\ln p(\mathbf{X},\mathbf{Z}|\theta)] = \sum_{\mathbf{Z}} \ln p(\mathbf{X},\mathbf{Z}|\theta) p(\mathbf{Z}|\mathbf{X},\theta^{old})`

E-step
-------
E-stepにおける隠れ変数の分布はカルマンスムーザーの方法を用いる

* :math:`p(\mathbf{Z}|\mathbf{X},\theta^{old})`

  * :math:`J_{n} = V_{n} A^{T} (P_{n})^{-1}`

  * :math:`\hat{\mu}_{n} = \mu_{n} + J_{n}(\hat{\mu}_{n+1} - A \mu_{n})`

  * :math:`\hat{V}_{n} = V_{n} + J_{n}(\hat{V}_{n+1} -P_{n})J_{n}^{T}`

  * :math:`E[z_{n}] = \hat{\mu_{n}}`

  * :math:`E[z_{n} z_{n-1}^{T}] = \hat{V}_{n} J_{n-1}^{T} + \hat{\mu}_{n} \hat{\mu}_{n-1}^{T}`

  * :math:`E[z_{n} z_{n}^{T}] = \hat{V}_{n} + \hat{\mu}_{n} \hat{\mu}_{n}^{T}`
<commit_msg>update docs<commit_after>パラメータ推定
=================

0. カルマンフィルタの尤度関数
-------------------------------

完全データX,Zが

:math:`l(\theta) = \ln p(X,Z|\theta) = \ln p(z_{0}|\mu_{0},P_{0})+ \sum_{n=2}^{N} \ln p(z_{n}|z_{n-1},F,Q)+ \sum_{n=1}^{N} \ln p(x_{n}|z_{n},H,R)`

:math:`\ln \mathcal{N} (\mathbf{x}|\mathbf{\mu},\mathbf{\Sigma}) = - \frac{D\ln(2 \pi)}{2}  -\frac{1}{2} \ln(|\Sigma|) -\frac{1}{2}(\mathbf{x}- \mathbf{\mu}) \Sigma^{-1}(\mathbf{x}- \mathbf{\mu})`


1. EMアルゴリズムを用いて求める
--------------------------------

パラメータ :math:`\theta = \lbrace A , \Gamma , C , \Sigma , \mu_{0} , P_{0} \rbrace` をEMアルゴリズムによって求める


* 完全データの対数尤度関数

  :math:`\ln p(\mathbf{X},\mathbf{Z}|\theta) = \ln(z_{1}|\mu_{0},P_{0}) + \sum_{n=2}^N \ln p(z_{n}|z_{n-1},A,\Gamma) + \sum_{n=1}^{N} \ln p(x_{n}|z_{n},C,\Sigma)`

* 完全データの尤度関数の期待値

  :math:`Q(\theta,\theta^{old})=E_{\mathbf{Z}|\theta^{old}}[\ln p(\mathbf{X},\mathbf{Z}|\theta)] = \sum_{\mathbf{Z}} \ln p(\mathbf{X},\mathbf{Z}|\theta) p(\mathbf{Z}|\mathbf{X},\theta^{old})`

E-step
-------
E-stepにおける隠れ変数の分布はカルマンスムーザーの方法を用いる

* :math:`p(\mathbf{Z}|\mathbf{X},\theta^{old})`

* :math:`J_{n} = V_{n} A^{T} (P_{n})^{-1}`

* :math:`\hat{\mu}_{n} = \mu_{n} + J_{n}(\hat{\mu}_{n+1} - A \mu_{n})`

* :math:`\hat{V}_{n} = V_{n} + J_{n}(\hat{V}_{n+1} -P_{n})J_{n}^{T}`

* :math:`E[z_{n}] = \hat{\mu_{n}}`

* :math:`E[z_{n} z_{n-1}^{T}] = \hat{V}_{n} J_{n-1}^{T} + \hat{\mu}_{n} \hat{\mu}_{n-1}^{T}`

* :math:`E[z_{n} z_{n}^{T}] = \hat{V}_{n} + \hat{\mu}_{n} \hat{\mu}_{n}^{T}`

{'fraction_non_alphanumeric': 0.394281914893617, 'fraction_numerical': 0.01928191489361702, 'mean_word_length': 3.5453172205438066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6423856', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1589, 'n_words': 171}