共分散,相関係数

 

・共分散

式で表すと,

\( \Large Cov[X,Y] = E[ (x_i - \mu_x) \cdot ( y_i - \mu_y)]\)

X,Yが独立の場合(ここ,を参考にしました),

\( \Large \begin{eqnarray} Cov[X,Y] &=& E[ x_i \cdot y_i - x_i \cdot \mu_y - \mu_x \cdot y_i + \mu_x \cdot \mu_y ] \\
&=& E[ x_i \cdot y_i] - E[x_i \cdot \mu_y] - E[\mu_x \cdot y_i] + E[\mu_x \cdot \mu_y ] \\
&=& E[ x_i \cdot y_i] - \mu_y \cdot E[x_i ] - \mu_x \cdot E[ y_i] + \mu_x \cdot \mu_y \\
&=& E[ x_i \cdot y_i] - \mu_y \cdot \mu_x - \mu_x \cdot \mu_y + \mu_x \cdot \mu_y \\
\end{eqnarray} \)

X,Yが独立の場合,\( \Large E[ x_i \cdot y_i ] = E[x_i] \cdot E[y_i] \),であるので,

\( \Large Cov[X,Y] = \mu_x \cdot \mu_y - \mu_y \cdot \mu_x - \mu_x \cdot \mu_y + \mu_x \cdot \mu_y = 0 \)

となります.

・相関係数

xi, yiの平均はそれぞれ, (ここ,を参考にしました,ありがとうございます.)

\( \Large \bar{x} = \frac{1}{n} \displaystyle \sum_{i=1}^n x_i \)

\( \Large \bar{y} = \frac{1}{n} \displaystyle \sum_{i=1}^n y_i \)

これは(1/nを無視すると)n次元のベクトルの内積となります.

\( \Large X = (x_1 - \bar{x}, \ x_2 - \bar{x}, \cdots , x_n - \bar{x} )\)

\( \Large X = (y_1 - \bar{y}, \ y_2 - \bar{y}, \cdots , y_n - \bar{y} )\)

内積の公式から,

\( \Large X \cdot Y = |X||Y| \ cos \theta \)

\( \Large \frac{X \cdot Y}{ |X||Y|} = cos \theta \)

となり,-1~1に規格化されます.これが相関係数です.

\( \Large R = \frac{\frac{1}{n} \displaystyle \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\frac{1}{n} \displaystyle \sum_{i=1}^n (x_i - \bar{x})^2}\sqrt{\frac{1}{n} \displaystyle \sum_{i=1}^n (y_i - \bar{y})^2}} \)

となります.

 

 

lt