$$$$
Def.
共分散
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$X,Y:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。
すなわち、
$$
\mathbb E[X^2]<\infty,\qquad \mathbb E[Y^2]<\infty
$$
が成り立つとする。このとき、$X$ と $Y$ の共分散 $\operatorname{Cov}(X,Y)$ を
$$
\operatorname{Cov}(X,Y)
:=
\mathbb E\left[(X-\mathbb E[X])(Y-\mathbb E[Y])\right]
$$
で定義する。
共分散が有限な実数として定義できる理由
$X,Y$ は二乗可積分であるから、$X,Y$ は可積分であり、
$$
\mathbb E[X]\in\mathbb R,\qquad \mathbb E[Y]\in\mathbb R
$$
である(
証明はコチラ
)。また、$X-\mathbb E[X]$ と $Y-\mathbb E[Y]$ も二乗可積分である。
したがって、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\mathbb E\left[\left|(X-\mathbb E[X])(Y-\mathbb E[Y])\right|\right]
\le
\left(\mathbb E[(X-\mathbb E[X])^2]\right)^{1/2}
\left(\mathbb E[(Y-\mathbb E[Y])^2]\right)^{1/2}
<
\infty
$$
である。よって、
$$
(X-\mathbb E[X])(Y-\mathbb E[Y])
$$
は可積分であり、$\operatorname{Cov}(X,Y)$ は有限な実数として定義される。
共分散の意味
共分散は、$X$ の平均からのずれ
$$
X-\mathbb E[X]
$$
と、$Y$ の平均からのずれ
$$
Y-\mathbb E[Y]
$$
の積の期待値である。
したがって、$X$ と $Y$ が平均から同じ向きにずれやすいとき、共分散は正になりやすい。
一方、$X$ と $Y$ が平均から反対向きにずれやすいとき、共分散は負になりやすい。
分散との関係
共分散は分散の一般化である。
実際、$X=Y$ とおくと、
$$
\operatorname{Cov}(X,X)
=
\mathbb E\left[(X-\mathbb E[X])^2\right]
=
\mathbb V(X)
$$
である。
したがって、
$$
\operatorname{Cov}(X,X)=\mathbb V(X)
$$
が成り立つ。
Prop&Proof
共分散と分散の関係
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$X:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。
すなわち、
$$
\mathbb E[X^2]<\infty
$$
が成り立つとする。
このとき、
$$
\operatorname{Cov}(X,X)=\mathbb V(X)
$$
が成り立つ。
$X$ は二乗可積分であるから、特に可積分である。
したがって、
$$
\mathbb E[X]\in\mathbb R
$$
である。ここで、
$$
\mu:=\mathbb E[X]
$$
とおく。共分散の定義より、
$$
\operatorname{Cov}(X,X)
=
\mathbb E\left[(X-\mathbb E[X])(X-\mathbb E[X])\right]
$$
である。$\mu=\mathbb E[X]$ であるから、
$$
\operatorname{Cov}(X,X)
=
\mathbb E\left[(X-\mu)(X-\mu)\right]
$$
である。
任意の $\omega\in\Omega$ に対して、
$$
(X(\omega)-\mu)(X(\omega)-\mu)
=
(X(\omega)-\mu)^2
$$
であるから、$\Omega$ 上の非負可測関数として
$$
(X-\mu)(X-\mu)=(X-\mu)^2
$$
である。
したがって、
$$
\begin{align}
\operatorname{Cov}(X,X)
&=
\mathbb E\left[(X-\mu)(X-\mu)\right] \\
&=
\mathbb E\left[(X-\mu)^2\right] \\
&=
\mathbb V(X)
\end{align}
$$
である。
以上より、
$$
\operatorname{Cov}(X,X)=\mathbb V(X)
$$
が成り立つ。
$$ \Box$$
共分散の対称性
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$X,Y:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。
すなわち、
$$
\mathbb E[X^2]<\infty,\qquad \mathbb E[Y^2]<\infty
$$
が成り立つとする。
このとき、
$$
\operatorname{Cov}(X,Y)=\operatorname{Cov}(Y,X)
$$
が成り立つ。
- $X,Y$ は二乗可積分であるから、特に可積分である。
そこで、
$$
\mu_X:=\mathbb E[X],\qquad \mu_Y:=\mathbb E[Y]
$$
とおく。このとき、
$$
\mu_X,\mu_Y\in\mathbb R
$$
である。
$ $
また、$X-\mu_X$ と $Y-\mu_Y$ は二乗可積分である。
実際、
$$
(X-\mu_X)^2\le 2X^2+2\mu_X^2
$$
であり(補足を参照)、右辺は可積分であるから、$X-\mu_X$ は二乗可積分である。
同様に、
$$
(Y-\mu_Y)^2\le 2Y^2+2\mu_Y^2
$$
であり、右辺は可積分であるから、$Y-\mu_Y$ もまた二乗可積分である。
$ $
したがって、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\mathbb E\left[\left|(X-\mu_X)(Y-\mu_Y)\right|\right]
\le
\left(\mathbb E[(X-\mu_X)^2]\right)^{1/2}
\left(\mathbb E[(Y-\mu_Y)^2]\right)^{1/2}
<
\infty
$$
である。
よって、$(X-\mu_X)(Y-\mu_Y)$ は可積分であり、$\operatorname{Cov}(X,Y)$ は有限な実数として定義される。
同様に、$(Y-\mu_Y)(X-\mu_X)$ も可積分であり、$\operatorname{Cov}(Y,X)$ も有限な実数として定義される。
$ $ - 共分散の定義より、
$$
\operatorname{Cov}(X,Y)
=
\mathbb E\left[(X-\mu_X)(Y-\mu_Y)\right]
$$
である。
また、実数の積は可換であるから、任意の $\omega\in\Omega$ に対して
$$
(X(\omega)-\mu_X)(Y(\omega)-\mu_Y)
=
(Y(\omega)-\mu_Y)(X(\omega)-\mu_X)
$$
が成り立つ。
したがって、$\Omega$ 上の実数値可測関数としてとして
$$
(X-\mu_X)(Y-\mu_Y)
=
(Y-\mu_Y)(X-\mu_X)
$$
である。
$ $ - よって、
$$
\begin{align}
\operatorname{Cov}(X,Y)
&=
\mathbb E\left[(X-\mu_X)(Y-\mu_Y)\right] \\
&=
\mathbb E\left[(Y-\mu_Y)(X-\mu_X)\right] \\
&=
\operatorname{Cov}(Y,X)
\end{align}
$$
である。
-以上より、
$$
\operatorname{Cov}(X,Y)=\operatorname{Cov}(Y,X)
$$
が成り立つ。
$$ \Box$$
仮定について
共分散を有限な実数として扱うためには、
$$
\mathbb E\left[\left|(X-\mathbb E[X])(Y-\mathbb E[Y])\right|\right]<\infty
$$
が必要である。
この命題では、$X,Y$ の二乗可積分性を仮定しているため、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式により、この可積分性が保証される。
したがって、$\operatorname{Cov}(X,Y)$ と $\operatorname{Cov}(Y,X)$ はどちらも有限な実数として定義される。
$(a+b)^2\le2a^2+2b^2$
任意の $x\in\mathbb R$ に対して $x^2\ge0$ であるから、任意の実数 $a,b$ について
$$
(a-b)^2\ge0
$$
が成り立つ。これを展開すると
$$
a^2-2ab+b^2\ge0
$$
である。従って
$$
2ab\le a^2+b^2
$$
が得られる。ここで
$$
(a+b)^2=a^2+2ab+b^2
$$
であるから、上の不等式 $2ab\le a^2+b^2$ を用いて
$$
(a+b)^2=a^2+2ab+b^2\le a^2+(a^2+b^2)+b^2=2a^2+2b^2
$$
となる。
$$ \Box$$
独立な確率変数の共分散
確率空間 $(\Omega,\mathcal F,\mathbb P)$ 上の実数値確率変数 $X,Y$ が
$$
\mathbb E[X^2]<\infty,\quad \mathbb E[Y^2]<\infty
$$
を満たし、かつ$X$と$Y$が独立であるとする。
このとき
$$
\mathbb E\Bigl[(X-\mathbb E[X])(Y-\mathbb E[Y])\Bigr]=0
$$
すなわち
$$
\mathrm{Cov}(X,Y)=0
$$
が成り立つ。
- 仮定$\mathbb E[X^2]<\infty$より、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式を用いて
$$
\mathbb E[|X|]\le \sqrt{\mathbb E[X^2]}<\infty
$$
が成り立つ。従って$\mathbb E[X]\in\mathbb R$が定まる。
同様に$\mathbb E[Y]\in\mathbb R$も定まる。
$ $ - 次に、$(a-b)^2\le 2a^2+2b^2$を用いると各$\omega\in\Omega$で
$$
(X-\mathbb E[X])^2\le 2X^2+2(\mathbb E[X])^2
$$
が成り立つので
$$
\mathbb E\Bigl[(X-\mathbb E[X])^2\Bigr]
\le 2\mathbb E[X^2]+2(\mathbb E[X])^2
<\infty
$$
である。
同様に
$$
\mathbb E\Bigl[(Y-\mathbb E[Y])^2\Bigr]<\infty
$$
も成り立つ。
従って$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より
$$
\mathbb E\Bigl[\bigl|(X-\mathbb E[X])(Y-\mathbb E[Y])\bigr|\Bigr]
\le
\sqrt{\mathbb E[(X-\mathbb E[X])^2]}\sqrt{\mathbb E[(Y-\mathbb E[Y])^2]}
<\infty
$$
となり、特に
$$
\mathbb E\Bigl[(X-\mathbb E[X])(Y-\mathbb E[Y])\Bigr]
$$
は有限実数として定義される。
$ $ - ここで
$$
U:=X-\mathbb E[X],\quad V:=Y-\mathbb E[Y]
$$
とおくと、$X$と$Y$が独立であり$\mathbb E[X],\mathbb E[Y]$は定数であるから、$U$と$V$も独立である(補足を参照)。
また、すでに示した通り
$$
\mathbb E[U^2]<\infty,\qquad \mathbb E[V^2]<\infty
$$
である。したがって、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より
$$
\mathbb E[|U|]\leq \sqrt{\mathbb E[U^2]}<\infty,
\qquad
\mathbb E[|V|]\leq \sqrt{\mathbb E[V^2]}<\infty
$$
である。
$ $ - また、$U$ と $V$ は独立であるから、
独立な可積分確率変数に対する積の期待値の公式(
証明はコチラ
)より
$$
\mathbb E[UV]=\mathbb E[U]\mathbb E[V]
$$
が成り立つ。ところが期待値の線形性(
証明はコチラ
)より
$$
\mathbb E[U]=\mathbb E[X-\mathbb E[X]]
=\mathbb E[X]-\mathbb E[X]
=0
$$
同様に$\mathbb E[V]=0$である。
従って
$$
\mathbb E\Bigl[(X-\mathbb E[X])(Y-\mathbb E[Y])\Bigr]
=\mathbb E[UV]
=\mathbb E[U]\mathbb E[V]
=0
$$
が成り立つ。
-共分散の定義より
$$
\mathrm{Cov}(X,Y)
:=\mathbb E\Bigl[(X-\mathbb E[X])(Y-\mathbb E[Y])\Bigr]
$$
なので$\mathrm{Cov}(X,Y)=0$が従う。
$$ \Box$$
$U$と$V$も独立
$X$と$Y$が独立であるとする。
ここで
$$
U:=X-\mathbb E[X],\quad V:=Y-\mathbb E[Y]
$$
とおく。
写像
$$
f(x):=x-\mathbb E[X],\quad g(y):=y-\mathbb E[Y]
$$
を用いれば$U=f(X)$、$V=g(Y)$であり、また、写像 $f,g$ は連続であるからボレル可測である。
したがって、任意のボレル集合 $A,B\in\mathcal B(\mathbb R)$ に対して、$f^{-1}(A),g^{-1}(B)\in\mathcal B(\mathbb R)$ である。
任意のボレル集合$A,B\subseteq\mathbb R$に対して
$$
\{U\in A\}=\{f(X)\in A\}=\{X\in f^{-1}(A)\},\quad
\{V\in B\}=\{g(Y)\in B\}=\{Y\in g^{-1}(B)\}
$$
が成り立つ。
したがって独立性より
$$
\mathbb P(U\in A,\ V\in B)
=\mathbb P\bigl(X\in f^{-1}(A),\ Y\in g^{-1}(B)\bigr)
=\mathbb P\bigl(X\in f^{-1}(A)\bigr)\mathbb P\bigl(Y\in g^{-1}(B)\bigr)
=\mathbb P(U\in A)\mathbb P(V\in B)
$$
となる。以上より$U$と$V$は独立である。
共分散の計算公式
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$X,Y:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。
すなわち、
$$
\mathbb E[X^2]<\infty,\qquad \mathbb E[Y^2]<\infty
$$
が成り立つとする。
このとき、
$$
\operatorname{Cov}(X,Y)
=
\mathbb E[XY]-\mathbb E[X]\mathbb E[Y]
$$
が成り立つ。
- $X,Y$ は二乗可積分であるから、特に可積分である。
したがって、
$$
\mathbb E[X]\in\mathbb R,\qquad \mathbb E[Y]\in\mathbb R
$$
である。
ここで、
$$
\mu_X:=\mathbb E[X],\qquad \mu_Y:=\mathbb E[Y]
$$
とおく。
また、$X$ と $Y$ は二乗可積分であるから、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\mathbb E[|XY|]
\le
\left(\mathbb E[X^2]\right)^{1/2}
\left(\mathbb E[Y^2]\right)^{1/2}
<
\infty
$$
である。よって、$XY$ は可積分である。
さらに、$\mu_XY$、$\mu_YX$、$\mu_X\mu_Y$ はいずれも可積分である。
$ $ - 共分散の定義より、
$$
\operatorname{Cov}(X,Y)
=
\mathbb E[(X-\mu_X)(Y-\mu_Y)]
$$
である。
任意の $\omega\in\Omega$ に対して、
$$
(X(\omega)-\mu_X)(Y(\omega)-\mu_Y)
=
X(\omega)Y(\omega)-\mu_XY(\omega)-\mu_YX(\omega)+\mu_X\mu_Y
$$
であるから、$\Omega$ 上の実数値可測関数としてとして
$$
(X-\mu_X)(Y-\mu_Y)
=
XY-\mu_XY-\mu_YX+\mu_X\mu_Y
$$
である。
$ $ - したがって、期待値の線形性、定数倍の性質、定数確率変数の期待値(
証明はコチラ
)より、
$$
\begin{align}
\operatorname{Cov}(X,Y)
&=
\mathbb E[(X-\mu_X)(Y-\mu_Y)]
&&\because \text{共分散の定義} \\
&=
\mathbb E[XY-X\mu_Y-\mu_XY+\mu_X\mu_Y]
&&\because \text{積の展開} \\
&=
\mathbb E[XY-\mu_YX-\mu_XY+\mu_X\mu_Y]
&&\because X\mu_Y=\mu_YX \\
&=
\mathbb E[XY]-\mathbb E[\mu_YX]-\mathbb E[\mu_XY]+\mathbb E[\mu_X\mu_Y]
&&\because \text{期待値の線形性} \\
&=
\mathbb E[XY]-\mu_Y\mathbb E[X]-\mu_X\mathbb E[Y]+\mu_X\mu_Y
&&\because \text{期待値の定数倍の性質と定数確率変数の期待値} \\
&=
\mathbb E[XY]-\mu_Y\mu_X-\mu_X\mu_Y+\mu_X\mu_Y
&&\because \mu_X=\mathbb E[X]\text{ かつ }\mu_Y=\mathbb E[Y] \\
&=
\mathbb E[XY]-\mu_X\mu_Y
&&\because \mu_Y\mu_X=\mu_X\mu_Y\text{ かつ }-\mu_X\mu_Y+\mu_X\mu_Y=0 \\
&=
\mathbb E[XY]-\mathbb E[X]\mathbb E[Y]
&&\because \mu_X=\mathbb E[X]\text{ かつ }\mu_Y=\mathbb E[Y]
\end{align}
$$
である。
-以上より、
$$
\operatorname{Cov}(X,Y)
=
\mathbb E[XY]-\mathbb E[X]\mathbb E[Y]
$$
が成り立つ。
$$ \Box$$
可積分性の注意
公式
$$
\operatorname{Cov}(X,Y)
=
\mathbb E[XY]-\mathbb E[X]\mathbb E[Y]
$$
を書くためには、$\mathbb E[XY]$ が有限な実数として定義されている必要がある。
この命題では、$X,Y$ の二乗可積分性を仮定しているため、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式により、
$$
\mathbb E[|XY|]<\infty
$$
が保証される。
線形結合の分散と共分散
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$n\in\mathbb N_{>0}$ とする。
$X_1,\dots,X_n:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。すなわち、任意の $i\in\{1,\dots,n\}$ に対して
$$
\mathbb E[X_i^2]<\infty
$$
が成り立つとする。
また、$a_1,\dots,a_n\in\mathbb R$ とし、
$$
S:=\sum_{j=1}^{n}a_jX_j
$$
とおく。
このとき、$S$ も二乗可積分であり、
$$
\mathbb V(S)
=
\sum_{i=1}^{n}\sum_{j=1}^{n}a_i a_j\operatorname{Cov}(X_i,X_j)
$$
が成り立つ。すなわち、
$$
\mathbb V\left(\sum_{j=1}^{n}a_jX_j\right)
=
\sum_{i=1}^{n}\sum_{j=1}^{n}a_i a_j\operatorname{Cov}(X_i,X_j)
$$
が成り立つ。
- まず、$S$ が二乗可積分であることを示す。
有限個の実数値確率変数の線形結合であるから、
$$
S=\sum_{j=1}^{n}a_jX_j
$$
も実数値確率変数である。
任意の実数 $b_1,\dots,b_n$ に対して、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\left(\sum_{j=1}^{n}b_j\right)^2
\le
n\sum_{j=1}^{n}b_j^2
$$
が成り立つ(補足を参照)。
これを
$$
b_j=a_jX_j(\omega)
$$
に適用すると、任意の $\omega\in\Omega$ に対して
$$
S(\omega)^2
=
\left(\sum_{j=1}^{n}a_jX_j(\omega)\right)^2
\le
n\sum_{j=1}^{n}a_j^2X_j(\omega)^2
$$
である。
したがって、$\Omega$ 上の非負可測関数として
$$
S^2
\le
n\sum_{j=1}^{n}a_j^2X_j^2
$$
が成り立つ。
期待値の単調性と線形性(
証明はコチラ
)より、
$$
\begin{align}
\mathbb E[S^2]
&\le
\mathbb E\left[n\sum_{j=1}^{n}a_j^2X_j^2\right]
&&\because S^2\le n\sum_{j=1}^{n}a_j^2X_j^2 \\
&=
n\sum_{j=1}^{n}a_j^2\mathbb E[X_j^2]
&&\because \text{期待値の線形性と定数倍の性質} \\
&<
\infty
&&\because \text{各 }X_j\text{ は二乗可積分であり、}a_j\in\mathbb R\text{ かつ }n\text{ は有限である}
\end{align}
$$
である。
したがって、$S$ は二乗可積分である。
$ $ - 次に、共分散が有限な実数として定義できることを確認する。
各 $X_i$ は二乗可積分であるから、特に可積分である。
そこで、
$$
\mu_i:=\mathbb E[X_i]\qquad (i=1,\dots,n)
$$
とおく。
このとき、
$$
\mu_i\in\mathbb R
$$
である。
各 $i\in\{1,\dots,n\}$ について、$X_i$ は二乗可積分であり、$\mu_i\in\mathbb R$ であるから、$X_i-\mu_i$ も二乗可積分である。
実際、
$$
(X_i-\mu_i)^2\le 2X_i^2+2\mu_i^2
$$
であり(補足を参照)、右辺は可積分である。
さらに、任意の $i,j\in\{1,\dots,n\}$ について、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\mathbb E\left[|(X_i-\mu_i)(X_j-\mu_j)|\right]
\le
\left(\mathbb E[(X_i-\mu_i)^2]\right)^{1/2}
\left(\mathbb E[(X_j-\mu_j)^2]\right)^{1/2}
<
\infty
$$
である。
したがって、$(X_i-\mu_i)(X_j-\mu_j)$ は可積分であり、
$$
\operatorname{Cov}(X_i,X_j)
=
\mathbb E[(X_i-\mu_i)(X_j-\mu_j)]
$$
は有限な実数として定義される。
$ $ - 次に、分散を計算する。
期待値の線形性(
証明はコチラ
)より、
$$
\mathbb E[S]
=
\mathbb E\left[\sum_{j=1}^{n}a_jX_j\right]
=
\sum_{j=1}^{n}a_j\mathbb E[X_j]
=
\sum_{j=1}^{n}a_j\mu_j
$$
である。
したがって、
$$
S-\mathbb E[S]
=
\sum_{j=1}^{n}a_jX_j-\sum_{j=1}^{n}a_j\mu_j
=
\sum_{j=1}^{n}a_j(X_j-\mu_j)
$$
である。
分散の定義より、
$$
\begin{align}
\mathbb V(S)
&=
\mathbb E\left[(S-\mathbb E[S])^2\right]
&&\because \text{分散の定義} \\
&=
\mathbb E\left[\left(\sum_{j=1}^{n}a_j(X_j-\mu_j)\right)^2\ \right]
&&\because S-\mathbb E[S]=\sum_{j=1}^{n}a_j(X_j-\mu_j)
\end{align}
$$
である。
ここで、和の二乗の展開公式(
詳しくはコチラ
)より、
$$
\left(\sum_{j=1}^{n}a_j(X_j-\mu_j)\right)^2
=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j(X_i-\mu_i)(X_j-\mu_j)
$$
である。
よって、期待値の線形性(
証明はコチラ
)より、
$$
\begin{align}
\mathbb V(S)
&=
\mathbb E\left[
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j(X_i-\mu_i)(X_j-\mu_j)
\right] \\
&=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j
\mathbb E[(X_i-\mu_i)(X_j-\mu_j)]
&&\because \text{期待値の線形性と定数倍の性質} \\
&=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j
\operatorname{Cov}(X_i,X_j)
&&\because \text{共分散の定義}
\end{align}
$$
である。
-以上より、
$$
\mathbb V(S)
=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j
\operatorname{Cov}(X_i,X_j)
$$
が成り立つ。$S=\sum_{j=1}^{n}a_jX_j$ であるから、
$$
\mathbb V\left(\sum_{j=1}^{n}a_jX_j\right)
=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j
\operatorname{Cov}(X_i,X_j)
$$
が成り立つ。
$$ \Box$$
$(a+b)^2\le2a^2+2b^2$
任意の $x\in\mathbb R$ に対して $x^2\ge0$ であるから、任意の実数 $a,b$ について
$$
(a-b)^2\ge0
$$
が成り立つ。これを展開すると
$$
a^2-2ab+b^2\ge0
$$
である。従って
$$
2ab\le a^2+b^2
$$
が得られる。ここで
$$
(a+b)^2=a^2+2ab+b^2
$$
であるから、上の不等式 $2ab\le a^2+b^2$ を用いて
$$
(a+b)^2=a^2+2ab+b^2\le a^2+(a^2+b^2)+b^2=2a^2+2b^2
$$
となる。
$$ \Box$$
$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式の使い方
有限個の実数 $a_1,\dots,a_n$ に対して
$$
\left(\sum_{i=1}^{n}a_i\right)^2
\le
n\sum_{i=1}^{n}a_i^2
$$
が成り立つ理由は、有限列に対する $\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式を、以下の$2$ つの列
$$
(a_1,\dots,a_n),\quad (1,\dots,1)
$$
に適用するからである。
有限列に対する $\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式は、
$$
\left(\sum_{i=1}^{n}a_i b_i\right)^2
\le
\left(\sum_{i=1}^{n}a_i^2\right)
\left(\sum_{i=1}^{n}b_i^2\right)
$$
である。
ここで、任意の $i\in\{1,\dots,n\}$ に対して
$$
b_i:=1
$$
とおくと、
$$
\sum_{i=1}^{n}a_i b_i
=
\sum_{i=1}^{n}a_i\cdot 1
=
\sum_{i=1}^{n}a_i
$$
であり、また
$$
\sum_{i=1}^{n}b_i^2
=
\sum_{i=1}^{n}1^2
=
\sum_{i=1}^{n}1
=
n
$$
である。
したがって、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より、
$$
\left(\sum_{i=1}^{n}a_i\right)^2
=
\left(\sum_{i=1}^{n}a_i\cdot 1\right)^2
\le
\left(\sum_{i=1}^{n}a_i^2\right)
\left(\sum_{i=1}^{n}1^2\right)
=
n\sum_{i=1}^{n}a_i^2
$$
が従う。
つまり、この不等式は、$a_1,\dots,a_n$ の和を、ベクトル $(a_1,\dots,a_n)$ とベクトル $(1,\dots,1)$ の内積と見て、
$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式を適用したものである。
行列形式
$\mathbf a\in\mathbb R^n$ を
$$
\mathbf a:=
\begin{pmatrix}
a_1\\
\vdots\\
a_n
\end{pmatrix}
$$
で定める。
また、共分散行列 $\Sigma$ を
$$
\Sigma:=
\left(\operatorname{Cov}(X_i,X_j)\right)_{1\le i,j\le n}
$$
で定める。
このとき、
$$
\mathbf a^{\top}\Sigma\mathbf a
=
\sum_{i=1}^{n}\sum_{j=1}^{n}
a_i a_j\operatorname{Cov}(X_i,X_j)
$$
である。
したがって、上の公式は行列形式で
$$
\mathbb V(S)=\mathbf a^{\top}\Sigma\mathbf a
$$
と書ける。
任意の $i\in\{1,\dots,n\}$ について $a_i=1$ とおくと、
$$
S=\sum_{i=1}^{n}X_i
$$
であり、公式は
$$
\mathbb V\left(\sum_{i=1}^{n}X_i\right)
=
\sum_{i=1}^{n}\sum_{j=1}^{n}
\operatorname{Cov}(X_i,X_j)
$$
となる。
これは、有限和の分散と共分散の公式に一致する。
共分散に対するコーシー・シュワルツの不等式
$(\Omega,\mathcal F,\mathbb P)$ を確率空間とし、$X,Y:\Omega\to\mathbb R$ を二乗可積分な実数値確率変数とする。
すなわち、
$$
\mathbb E[X^2]<\infty,\qquad \mathbb E[Y^2]<\infty
$$
が成り立つとする。
共分散を
$$
\operatorname{Cov}(X,Y)
:=
\mathbb E\left[(X-\mathbb E[X])(Y-\mathbb E[Y])\right]
$$
で定義する。
このとき、
$$
|\operatorname{Cov}(X,Y)|
\le
\sqrt{\mathbb V(X)\mathbb V(Y)}
$$
が成り立つ。
- $X,Y$ は二乗可積分であるから、特に可積分である。
したがって、
$$
\mathbb E[X]\in\mathbb R,\qquad \mathbb E[Y]\in\mathbb R
$$
である。
ここで、
$$
\mu_X:=\mathbb E[X],\qquad \mu_Y:=\mathbb E[Y]
$$
とおく。まず、
$$
X-\mu_X,\qquad Y-\mu_Y
$$
が二乗可積分であることを確認する。
任意の $\omega\in\Omega$ に対して、
$$
(X(\omega)-\mu_X)^2\le 2X(\omega)^2+2\mu_X^2
$$
である(補足を参照)から、
$$
\begin{align}
\mathbb E[(X-\mu_X)^2]
&\le
2\mathbb E[X^2]+2\mu_X^2 \\
&<
\infty
\end{align}
$$
である。
同様に、任意の $\omega\in\Omega$ に対して、
$$
(Y(\omega)-\mu_Y)^2\le 2Y(\omega)^2+2\mu_Y^2
$$
である(補足を参照)から、
$$
\begin{align}
\mathbb E[(Y-\mu_Y)^2]
&\le
2\mathbb E[Y^2]+2\mu_Y^2 \\
&<
\infty
\end{align}
$$
である。
$ $ - したがって、$\Omega$ 上の関数 $X-\mu_X$ と $Y-\mu_Y$ に対して、積分形の $\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式を適用できる。
すなわち、
$$
\left|
\int_\Omega
(X-\mu_X)(Y-\mu_Y)\,d\mathbb P
\right|
\le
\left(\int_\Omega (X-\mu_X)^2\,d\mathbb P\right)^{1/2}
\left(\int_\Omega (Y-\mu_Y)^2\,d\mathbb P\right)^{1/2}
$$
が成り立つ。
ここで、共分散の定義より、
$$
\operatorname{Cov}(X,Y)
=
\mathbb E[(X-\mu_X)(Y-\mu_Y)]
=
\int_\Omega
(X-\mu_X)(Y-\mu_Y)\,d\mathbb P
$$
である。
また、分散の定義より、
$$
\mathbb V(X)
=
\mathbb E[(X-\mu_X)^2]
=
\int_\Omega (X-\mu_X)^2\,d\mathbb P
$$
かつ
$$
\mathbb V(Y)
=
\mathbb E[(Y-\mu_Y)^2]
=
\int_\Omega (Y-\mu_Y)^2\,d\mathbb P
$$
である。
したがって、
$$
\begin{align}
|\operatorname{Cov}(X,Y)|
&=
\left|
\int_\Omega
(X-\mu_X)(Y-\mu_Y)\,d\mathbb P
\right|
&&\because \text{共分散の定義} \\
&\le
\left(\int_\Omega (X-\mu_X)^2\,d\mathbb P\right)^{1/2}
\left(\int_\Omega (Y-\mu_Y)^2\,d\mathbb P\right)^{1/2}
&&\because \mathrm{Cauchy}\text{-}\mathrm{Schwarz}\text{ の不等式} \\
&=
\sqrt{\mathbb V(X)}\sqrt{\mathbb V(Y)}
&&\because \text{分散の定義} \\
&=
\sqrt{\mathbb V(X)\mathbb V(Y)}
\end{align}
$$
である。
-以上より、
$$
|\operatorname{Cov}(X,Y)|
\le
\sqrt{\mathbb V(X)\mathbb V(Y)}
$$
が成り立つ。
$$ \Box$$
相関係数へのつながり
$\mathbb V(X)>0$ かつ $\mathbb V(Y)>0$ のとき、相関係数を
$$
\rho(X,Y)
:=
\frac{\operatorname{Cov}(X,Y)}
{\sqrt{\mathbb V(X)\mathbb V(Y)}}
$$
で定義する。上の命題より、
$$
|\rho(X,Y)|\le1
$$
が成り立つ。
つまり、相関係数は常に $-1$ 以上 $1$ 以下の値をとる。
分散が $0$ の場合
もし $\mathbb V(X)=0$ または $\mathbb V(Y)=0$ ならば、右辺は
$$
\sqrt{\mathbb V(X)\mathbb V(Y)}=0
$$
である。
この場合も、$\mathrm{Cauchy}$-$\mathrm{Schwarz}$ の不等式より
$$
|\operatorname{Cov}(X,Y)|\le0
$$
となるため、
$$
\operatorname{Cov}(X,Y)=0
$$
である。
したがって、不等式はこの場合にも成り立つ。
$(a+b)^2\le2a^2+2b^2$
任意の $x\in\mathbb R$ に対して $x^2\ge0$ であるから、任意の実数 $a,b$ について
$$
(a-b)^2\ge0
$$
が成り立つ。これを展開すると
$$
a^2-2ab+b^2\ge0
$$
である。従って
$$
2ab\le a^2+b^2
$$
が得られる。ここで
$$
(a+b)^2=a^2+2ab+b^2
$$
であるから、上の不等式 $2ab\le a^2+b^2$ を用いて
$$
(a+b)^2=a^2+2ab+b^2\le a^2+(a^2+b^2)+b^2=2a^2+2b^2
$$
となる。
$$ \Box$$