中心為 (0, 0) 的一個二元高斯機率密度函數,共變異數矩陣為 [ 1.00, 0.50 ; 0.50, 1.00 ]。
一個左下右上方向標準差為 3,正交方向標準差為 1 的多元高斯分布的樣本點。由於 x 和 y 分量共變(即相關),x 與 y 的變異數不能完全描述該分布;箭頭的方向對應的共變異數矩陣的特徵向量,其長度為特徵值的平方根。
在統計學與機率論中,共變異數矩陣(covariance matrix)是一個方陣,代表著任兩列隨機變數間的共變異數,是共變異數的直接推廣。
定義 —
設
是機率空間,
與
是定義在
上的兩列實數隨機變數序列
若二者對應的期望值分別為:


則這兩列隨機變量間的共變異數矩陣為:
![{\displaystyle \operatorname {\mathbf {cov} } (X,Y):={\left[\,\operatorname {cov} (x_{i},y_{j})\,\right]}_{m\times n}={{\bigg [}\,\operatorname {E} [(x_{i}-\mu _{i})(y_{j}-\nu _{j})]\,{\bigg ]}}_{m\times n}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a5156794b781f959d02adb93d3b439bfb543fdf3)
將之以矩形表示的話就是:

![{\displaystyle ={\begin{bmatrix}\mathrm {E} [(x_{1}-\mu _{1})(y_{1}-\nu _{1})]&\mathrm {E} [(x_{1}-\mu _{1})(y_{2}-\nu _{2})]&\cdots &\mathrm {E} [(x_{1}-\mu _{1})(y_{n}-\nu _{n})]\\\mathrm {E} [(x_{2}-\mu _{2})(y_{1}-\nu _{1})]&\mathrm {E} [(x_{2}-\mu _{2})(y_{2}-\nu _{2})]&\cdots &\mathrm {E} [(x_{2}-\mu _{2})(y_{n}-\nu _{n})]\\\vdots &\vdots &\ddots &\vdots \\\mathrm {E} [(x_{m}-\mu _{m})(y_{1}-\nu _{1})]&\mathrm {E} [(x_{m}-\mu _{m})(y_{2}-\nu _{2})]&\cdots &\mathrm {E} [(x_{m}-\mu _{m})(y_{n}-\nu _{n})]\end{bmatrix}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/7e9a5a14766d082923ed9e794213088c3c32d7ac)
根據測度積分的線性性質,共變異數矩陣還可以進一步化簡為:
![{\displaystyle \operatorname {\mathbf {cov} } (X,Y)={\left[\,\operatorname {E} (x_{i}y_{j})-\mu _{i}\nu _{j}\,\right]}_{n\times n}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a813988c7371dfa7dedb84fdaaf86a286bf02b38)
以上定義所述的隨機變數序列
和
,也可分別以用行向量
與
表示,換句話說:

這樣的話,對於
個定義在
上的隨機變數
所組成的矩陣
, 定義:
![{\displaystyle \mathrm {E} [\mathbf {A} ]:={\left[\,\operatorname {E} (a_{ij})\,\right]}_{m\times n}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/60afd661ab70521d030a0a969b98b5f27fd970b1)
也就是說
![{\displaystyle \mathrm {E} [\mathbf {A} ]:={\begin{bmatrix}\operatorname {E} (a_{11})&\operatorname {E} (a_{12})&\cdots &\operatorname {E} (a_{1n})\\\operatorname {E} (a_{21})&\operatorname {E} (a_{22})&\cdots &\operatorname {E} (a_{2n})\\\vdots &\vdots &\ddots &\vdots \\\operatorname {E} (a_{m1})&\operatorname {E} (a_{m2})&\cdots &\operatorname {E} (a_{mn})\end{bmatrix}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/83249bbd99a43a8ea8379d8a17a55fdbcf1e4f89)
那上小節定義的共變異數矩陣就可以記為:
![{\displaystyle \operatorname {\mathbf {cov} } (X,Y)=\mathrm {E} \left[\left(\mathbf {X} -\mathrm {E} [\mathbf {X} ]\right)\left(\mathbf {Y} -\mathrm {E} [\mathbf {Y} ]\right)^{\rm {T}}\right]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/89f92295929a9d0e5ddbc2c184f2aff142268c7d)
所以共變異數矩陣也可對
與
來定義:
![{\displaystyle \operatorname {\mathbf {cov} } (\mathbf {X} ,\mathbf {Y} ):=\mathrm {E} \left[\left(\mathbf {X} -\mathrm {E} [\mathbf {X} ]\right)\left(\mathbf {Y} -\mathrm {E} [\mathbf {Y} ]\right)^{\rm {T}}\right]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b03cb33d4dec223e53e0ca7875851a47fdfb66db)
也有人把以下的
稱為共變異數矩陣:
![{\displaystyle {\begin{aligned}\mathbf {\Sigma } _{X}&:={\left[\operatorname {cov} (x_{i},x_{j})\right]}_{m\times m}\\&=\operatorname {\mathbf {cov} } (X,X)\end{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a31fca254cb3233a0b0aaa7840af35d0ef361307)
但本頁面沿用威廉·費勒的說法,把
稱為
的變異數(variance of random vector),來跟
作區別。這是因為:
![{\displaystyle \operatorname {cov} (x_{i},x_{i})=\operatorname {E} [{(x_{i}-\mu _{i})}^{2}]=\operatorname {var} (x_{i})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f698aa1156b519c0dd1cadb8440b3b4c8c042ec0)
換句話說,
的對角線由隨機變數
的變異數所組成。據此,也有人也把
稱為變異數-共變異數矩陣(variance–covariance matrix)。
更有人因為變異數和離差的相關性,含混的將
稱為離差矩陣。
有以下的基本性質:
![{\displaystyle \mathbf {\Sigma } =\mathrm {E} (\mathbf {X} \mathbf {X} ^{T})-\mathrm {E} (\mathbf {X} ){[\mathrm {E} (\mathbf {X} )]}^{T}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f467eb02422f2ac50eae7beff565c80fe03ae8e4)
是半正定的和對稱的矩陣。





- 若
,則有

- 若
與
是獨立的,則有

儘管共變異數矩陣很簡單,可它卻是很多領域裡的非常有力的工具。它能導出一個轉換矩陣,這個矩陣能使數據完全去相關(decorrelation)。從不同的角度看,也就是說能夠找出一組最佳的基以緊湊的方式來表達數據。(完整的證明請參考瑞利商)。
這個方法在統計學中被稱為主成分分析(principal components analysis),在圖像處理中稱為Karhunen-Loève 轉換(KL-轉換)。
均值為
的複隨機純量變量的變異數定義如下(使用共軛複數):
![{\displaystyle \operatorname {var} (z)=\operatorname {E} \left[(z-\mu )(z-\mu )^{*}\right]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/c660060a82fca0c8cb8dc94bf04136bc62d02d27)
其中複數
的共軛記為
。
如果
是一個複列向量,則取其共軛轉置,得到一個方陣:
![{\displaystyle \operatorname {E} \left[(Z-\mu )(Z-\mu )^{*}\right]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ef98d37f31cddf1eb47261f0bb4ba0942202ea40)
其中
為共軛轉置, 它對於純量也成立,因為純量的轉置還是純量。
多元常態分布的共變異數矩陣的估計的推導非常精緻. 它需要用到譜定義以及為什麼把純量看做
矩陣的跡更好的原因。參見共變異數矩陣的估計。