0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

2変量正規分布

Last updated at Posted at 2024-06-07

今回は多変量正規分布から2変量正規分布を求めます。
多変量正規分布の公式

\begin{align}
f(\mathbf{x}) = \frac{1}{(2\pi)^{\frac{n}{2}} \left(\mathbf{det\Sigma}\right)^{\frac{1}{2}}} \exp \left( -\frac{1}{2} (\mathbf{x} - \mathbf{\mu})^\top \mathbf{\Sigma}^{-1} (\mathbf{x} - \mathbf{\mu}) \right)  \\
 または  f(\mathbf{x}) = \frac{1}{(2\pi)^{\frac{n}{2}} \left|\mathbf{\Sigma}\right|^{\frac{1}{2}}} \exp \left( -\frac{1}{2} (\mathbf{x} - \mathbf{\mu})^\top \mathbf{\Sigma}^{-1} (\mathbf{x} - \mathbf{\mu}) \right)
\end{align}

2変量正規分布の公式

f(x_1, x_2) = \frac{1}{2\pi \sqrt{(1-\rho^2)\sigma_1^2 \sigma_2^2}} \exp \left( -\frac{1}{2(1-\rho^2)} \left\{ \frac{(x_1 - \mu_1)^2}{\sigma_1^2} - 2\rho \left( \frac{(x_1 - \mu_1)}{\sigma_1} \right) \left( \frac{(x_2 - \mu_2)}{\sigma_2} \right) + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right\} \right)

理解しやすいように5ステップで考えます。

\displaylines{
 1.\Sigma^{-1}を求める \\
 2.|\Sigma| (det\Sigma)を求める \\
 3.多変量正規分布に1.と2.で求めたものを代入して整理する \\ 
 4.expまたはeの右側を考える \\ 
 5.最後に整理する(終了)}

今回使う条件

\begin{align}
X &= 
\begin{pmatrix}
x_1 & x_2
\end{pmatrix}^\top \\

\mu &=
\begin{pmatrix}
\mu_1 & \mu_2
\end{pmatrix}^\top \\

\Sigma &= 
\begin{pmatrix}
\sigma_1^2 & \rho \sigma_1 \sigma_2 \\
\rho \sigma_1 \sigma_2 & \sigma_2^2
\end{pmatrix}
\end{align}

1.

2×2の逆行列より

\begin{align}
\mathbf{\Sigma}^{-1} &= \frac{1}{\sigma_1^2 \sigma_2^2 - \rho \sigma_1 \sigma_2\rho \sigma_1 \sigma_2}
\begin{pmatrix}
\sigma_2^2 & -\rho \sigma_1 \sigma_2 \\
-\rho \sigma_1 \sigma_2 & \sigma_1^2
\end{pmatrix} \\ 

&= \frac{1}{\sigma_1^2 \sigma_2^2 - \rho^2 \sigma_1^2 \sigma_2^2}
\begin{pmatrix}
\sigma_2^2 & -\rho \sigma_1 \sigma_2 \\
-\rho \sigma_1 \sigma_2 & \sigma_1^2
\end{pmatrix} \\ 

&= \frac{1}{(1 - \rho^2) \sigma_1^2 \sigma_2^2}
\begin{pmatrix}
\sigma_2^2 & -\rho \sigma_1 \sigma_2 \\
-\rho \sigma_1 \sigma_2 & \sigma_1^2
\end{pmatrix}
\end{align}

逆行列がわからない方へ

2.

2次元正方行列より

\begin{align}

det\Sigma &= \sigma_1^2\sigma_2^2 - \rho^2\sigma_1^2\sigma_2^2 \\
&= (1-\rho^2)\sigma_1^2\sigma_2^2
\end{align}

正方行列がわからない方へ

3.

 ※(2\pi)^{\frac{n}{2}}のnは2より2\pi^1となる
\frac{1}{2\pi \sqrt{(1-\rho^2)\sigma_1^2 \sigma_2^2}} \exp \left( -\frac{1}{2} (\mathbf{x} - \mathbf{\mu})^\top\frac{1}{(1-\rho^2)\sigma_1^2 \sigma_2^2} 
\begin{pmatrix}
\sigma_2^2 & -\rho \sigma_1 \sigma_2 \\
-\rho \sigma_1 \sigma_2 & \sigma_1^2
\end{pmatrix}
(\mathbf{x} - \mathbf{\mu}) \right)

4.

\begin{align}
(\mathbf{x} - \mathbf{\mu})^\top \mathbf{\Sigma}^{-1} 
(x-\mu) &=  
\begin{pmatrix}
x_1 - \mu_1 & x_2 - \mu_2
\end{pmatrix}
\frac{1}{(1 - \rho^2) \sigma_1^2 \sigma_2^2}
\begin{pmatrix}
\sigma_2^2 & -\rho \sigma_1 \sigma_2 \\
-\rho \sigma_1 \sigma_2 & \sigma_1^2
\end{pmatrix}
\begin{pmatrix}
x_1 - \mu_1 \\
x_2 - \mu_2
\end{pmatrix} \\
&= \frac{1}{(1 - \rho^2) \sigma_1^2 \sigma_2^2}
\begin{pmatrix}
\sigma_2^2(x_1-\mu_1)-
\rho\sigma_1\sigma_2(x_2-\mu_2) & 
-\rho\sigma_1\sigma_2(x_1-\mu_1)+
\sigma_1^2(x_2-\mu_2) 
\end{pmatrix}
\begin{pmatrix}
x_1 - \mu_1 \\
x_2 - \mu_2
\end{pmatrix}\\

&= \frac{1}{(1 - \rho^2) \sigma_1^2 \sigma_2^2}
(
\sigma_2^2(x_1-\mu_1)^2-
\rho\sigma_1\sigma_2(x_2-\mu_2)(x_1-\mu_1) 
-\rho\sigma_1\sigma_2(x_1-\mu_1)(x_2-\mu_2)+
\sigma_1^2(x_2-\mu_2)^2 
)
\\

&= \frac{1}{(1 - \rho^2) \sigma_1^2 \sigma_2^2}
(
\sigma_2^2(x_1-\mu_1)^2
-2\rho\sigma_1\sigma_2(x_2-\mu_2)(x_1-\mu_1) 
+\sigma_1^2(x_2-\mu_2)^2 
)
\\

&= \frac{1}{1 - \rho^2}
(
\frac{(x_1-\mu_1)^2}{\sigma_1^2}
-2\rho \frac{(x_2-\mu_2)(x_1-\mu_1)}{\sigma_1\sigma_2}
+\frac{(x_2-\mu_2)^2}{\sigma_2^2}
)
\\


&= \frac{1}{1 - \rho^2} \left( \frac{(x_1 - \mu_1)^2}{\sigma_1^2} - 2\rho \left( \frac{(x_1 - \mu_1)}{\sigma_1} \right) \left( \frac{(x_2 - \mu_2)}{\sigma_2} \right) + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right)
\end{align}

$$※\frac{(x_2-\mu_2)(x_1-\mu_1)}{\sigma_1\sigma_2}は標準化しているので分ける(=が下から2番目)$$

5.

f(x_1, x_2) = \frac{1}{2\pi \sqrt{(1-\rho^2)\sigma_1^2 \sigma_2^2}} \exp \left( -\frac{1}{2(1-\rho^2)} \left\{ \frac{(x_1 - \mu_1)^2}{\sigma_1^2} - 2\rho \left( \frac{(x_1 - \mu_1)}{\sigma_1} \right) \left( \frac{(x_2 - \mu_2)}{\sigma_2} \right) + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right\} \right)

参考にしたサイトと本

統計検定実践ワークブック

スクリーンショット 2024-06-07 7.01.01.png

番外編1(2変量正規分布が無相関(p=0)の時の証明)

\begin{align}
f(x_1, x_2) &= \frac{1}{2\pi \sqrt{(1-\rho^2)\sigma_1^2 \sigma_2^2}} \exp \left( -\frac{1}{2(1-\rho^2)} \left\{ \frac{(x_1 - \mu_1)^2}{\sigma_1^2} - 2\rho \left( \frac{(x_1 - \mu_1)}{\sigma_1} \right) \left( \frac{(x_2 - \mu_2)}{\sigma_2} \right) + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right\} \right) \\
&= \frac{1}{2\pi\sqrt{\sigma_1^2 \sigma_2^2}}\exp
\left( -\frac{1}{2} \left\{\frac{(x_1 - \mu_1)^2}{\sigma_1^2}  + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right\} \right) \\
&= \frac{1}{\sqrt{4\pi^2\sigma_1^2 \sigma_2^2}}\exp
\left( - \frac{(x_1 - \mu_1)^2}{2\sigma_1^2} -\frac{(x_2 - \mu_2)^2}{2\sigma_2^2} \right) \\
&= \frac{1}{\sqrt{2\pi\sigma_1^2} \sqrt{2\pi\sigma_2^2}}\exp
\left( - \frac{(x_1 - \mu_1)^2}{2\sigma_1^2} -\frac{(x_2 - \mu_2)^2}{2\sigma_2^2} \right) \\
&= \frac{1}{\sqrt{2\pi\sigma_1^2}}\exp\left( - \frac{(x_1 - \mu_1)^2}{2\sigma_1^2} \right) ・
\frac{1}{\sqrt{2\pi\sigma_2^2}}\exp\left( -\frac{(x_2 - \mu_2)^2}{2\sigma_2^2} \right) \\
&= f(x_1) ・ f(x_2)
\end{align}

番外編2(2つの正規分布が同じである時の証明)

平均0 分散1の時

\begin{align}
f(x_1, x_2) &= \frac{1}{2\pi \sqrt{(1-\rho^2)\sigma_1^2 \sigma_2^2}} \exp \left( -\frac{1}{2(1-\rho^2)} \left\{ \frac{(x_1 - \mu_1)^2}{\sigma_1^2} - 2\rho \left( \frac{(x_1 - \mu_1)}{\sigma_1} \right) \left( \frac{(x_2 - \mu_2)}{\sigma_2} \right) + \frac{(x_2 - \mu_2)^2}{\sigma_2^2} \right\} \right) \\
&= \frac{1}{2\pi\sqrt{(1-\rho^2)}} \exp \left( -\frac{1}{2(1-\rho^2)} (x_1^2 -2\rho x_1x_2 + x_2^2) \right)

\end{align}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?