<h4>マハラノビス距離の計算:共分散を考慮した距離測定</h4><div class='key-point'><div class='key-point-title'>マハラノビス距離の重要性</div><p>マハラノビス距離は、変数間の相関と分散の違いを考慮した距離尺度です。単純なユークリッド距離とは異なり、データの分布形状を反映するため、多変量統計解析において外れ値検出や分類問題で重要な役割を果たします。</p></div><h4>マハラノビス距離の計算手順</h4><p class='step'><strong>Step 1: マハラノビス距離の定義</strong></p><p>観測値$\mathbf{x}$と平均$\boldsymbol{\mu}$間のマハラノビス距離:</p><div class='formula'>$d_M(\mathbf{x}) = \sqrt{(\mathbf{x} - \boldsymbol{\mu})^T \mathbf{S}^{-1} (\mathbf{x} - \boldsymbol{\mu})}
lt;/div><p>ここで:</p><ul><li>$\mathbf{x}$:観測値ベクトル</li><li>$\boldsymbol{\mu}$:平均ベクトル</li><li>$\mathbf{S}$:共分散行列</li><li>$\mathbf{S}^{-1}$:共分散行列の逆行列</li></ul><p class='step'><strong>Step 2: 与えられた値の確認</strong></p><ul><li><strong>平均ベクトル</strong>:$\boldsymbol{\mu} = \begin{pmatrix} 1 \\ 2 \end{pmatrix}
lt;/li><li><strong>共分散行列</strong>:$\mathbf{S} = \begin{pmatrix} 4 & 2 \\ 2 & 2 \end{pmatrix}
lt;/li><li><strong>観測値</strong>:$\mathbf{x} = \begin{pmatrix} 3 \\ 4 \end{pmatrix}
lt;/li></ul><p class='step'><strong>Step 3: 差分ベクトルの計算</strong></p><div class='formula'>$(\mathbf{x} - \boldsymbol{\mu}) = \begin{pmatrix} 3 \\ 4 \end{pmatrix} - \begin{pmatrix} 1 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \end{pmatrix}
lt;/div><p class='step'><strong>Step 4: 共分散行列の逆行列計算</strong></p><p>2×2行列の逆行列公式:$\mathbf{A}^{-1} = \frac{1}{\det(\mathbf{A})} \begin{pmatrix} a_{22} & -a_{12} \\ -a_{21} & a_{11} \end{pmatrix}
lt;/p><p><strong>行列式の計算:</strong></p><div class='formula'>$\det(\mathbf{S}) = 4 \times 2 - 2 \times 2 = 8 - 4 = 4
lt;/div><p><strong>逆行列:</strong></p><div class='formula'>$\mathbf{S}^{-1} = \frac{1}{4} \begin{pmatrix} 2 & -2 \\ -2 & 4 \end{pmatrix} = \begin{pmatrix} 0.5 & -0.5 \\ -0.5 & 1.0 \end{pmatrix}
lt;/div><p class='step'><strong>Step 5: 二次形式の計算</strong></p><p>$(\mathbf{x} - \boldsymbol{\mu})^T \mathbf{S}^{-1} (\mathbf{x} - \boldsymbol{\mu})$を計算:</p><div class='formula'>$\begin{pmatrix} 2 & 2 \end{pmatrix} \begin{pmatrix} 0.5 & -0.5 \\ -0.5 & 1.0 \end{pmatrix} \begin{pmatrix} 2 \\ 2 \end{pmatrix}
lt;/div><p><strong>中間計算:</strong></p><div class='formula'>$\begin{pmatrix} 2 & 2 \end{pmatrix} \begin{pmatrix} 0.5 \times 2 + (-0.5) \times 2 \\ (-0.5) \times 2 + 1.0 \times 2 \end{pmatrix} = \begin{pmatrix} 2 & 2 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix}
lt;/div><div class='formula'>$= 2 \times 0 + 2 \times 1 = 2
lt;/div><p class='step'><strong>Step 6: マハラノビス距離の算出</strong></p><div class='formula'>$d_M(\mathbf{x}) = \sqrt{2}
lt;/div><div class='key-point'><h4>結果の検証と解釈</h4><table class='table table-bordered'><tr><th>距離の種類</th><th>値</th><th>計算</th></tr><tr><td><strong>ユークリッド距離</strong></td><td>$\sqrt{8} = 2\sqrt{2}
lt;/td><td>$\sqrt{2^2 + 2^2}
lt;/td></tr><tr><td><strong>マハラノビス距離</strong></td><td>$\sqrt{2}
lt;/td><td>共分散考慮済み</td></tr></table></div><h4>マハラノビス距離とユークリッド距離の比較</h4><p>この例では、マハラノビス距離($\sqrt{2}$)がユークリッド距離($2\sqrt{2}$)より小さくなっています。これは:</p><ul><li><strong>正の相関</strong>:変数間の共分散が正(2)のため</li><li><strong>楕円状分布</strong>:データが斜めの楕円状に分布</li><li><strong>実効距離の短縮</strong>:相関を考慮すると、実際の「離れ具合」は小さい</li></ul><div class='key-point'><h4>統計的性質</h4><p>多変量正規分布$N_p(\boldsymbol{\mu}, \mathbf{S})$からの観測値の場合:</p><div class='formula'>$d_M^2(\mathbf{x}) \sim \chi^2_p
lt;/div><p>この例では$p=2$なので、$d_M^2 = 2$は$\chi^2_2$分布に従います。</p></div>