「統計解析のための線形代数」復習筆記14
- updated: 2017-03-07
對稱矩陣
- \(A=\left( \begin{array}{c} 4 & 3 & 2 & 1 \\ 3 & 5 & 6 & 7 \\ 2 & 6 & 8 & 9 \\ 1 & 7 & 9 & 0 \end{array} \right)\) 是典型的4次對稱矩陣。
數學 | 物理 | 化學 | |
---|---|---|---|
數學 | \(1\) | \(0.72\) | \(0.62\) |
物理 | \(0.72\) | \(1\) | \(-0.55\) |
化學 | \(0.62\) | \(-0.55\) | \(1\) |
上表是幾名學生的數學,物理,化學成績得分的相關系數。
如果提取出數字的部分,左右用圓括號括起來,會得到這樣一個矩陣:\(R=\left( \begin{array}{c} 1 & 0.72 & 0.62 \\ 0.72 & 1 & -0.55 \\ 0.62 & -0.55 & 1 \\ \end{array} \right)\) 這樣類型的矩陣被特別的稱爲相關矩陣(correlation matrix)。類似相關矩陣這樣的明確爲對稱矩陣的情況下,常常像下面這樣簡略的記左下或者右上部分: \[\left( \begin{array}{c} 1 & & \\ 0.72 & 1 & \\ 0.62 & -0.55 & 1 \\ \end{array} \right), \left( \begin{array}{c} 1 & 0.72 & 0.62 \\ & 1 & -0.55 \\ & & 1 \\ \end{array} \right)\]下面的對稱矩陣,對角成分是方差(variance, 分散),非對角成分是協方差(covariance, 共分散),被稱爲方差協方差矩陣(variance-covariance matrix, 分散共分散行列)。
\[\sum=\left( \begin{array}{c} \sigma_{1}^2 & \sigma_{2} & \cdots & \sigma_{1n} \\ \sigma_{12} & \sigma_{2}^2 & \cdots & \sigma_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ \sigma_{1n} & \sigma_{2} & \cdots & \sigma_{n}^2 \end{array} \right), S=\left( \begin{array}{c} s_{1}^2 & s_{2} & \cdots & s_{1n} \\ s_{12} & s_{2}^2 & \cdots & s_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ s_{1n} & s_{2} & \cdots & s_{n}^2 \end{array} \right)\]矩陣\(X=\left( \begin{array}{c} x_{11} & x_{12} & x_{13} \\ x_{21} & x_{22} & x_{23} \\ \end{array} \right)\) ,那麼,
\(XX^t=\left( \begin{array}{c} x_{11} & x_{12} & x_{13} \\ x_{21} & x_{22} & x_{23} \\ \end{array} \right)\left( \begin{array}{c} x_{11} & x_{12} \\ x_{12} & x_{22} \\ x_{13} & x_{13} \end{array} \right)\\ \;\;\;\;\;\;\;=\left( \begin{array}{c} x_{11}^2+x_{12}^2+x_{13}^2 & x_{11}x_{21}+x_{12}x_{22}+x_{13}x_{23} \\ x_{21}x_{11}+x_{22}x_{12}+x_{23}x_{13} & x_{21}^2+x_{22}^2+x_{23}^2 \\ \end{array} \right)\) 是一個對稱矩陣。
\(X^tX=\left( \begin{array}{c} x_{11}^2+x_{21}^2 & x_{11}x_{12}+x_{21}x_{22} & x_{11}x_{13}+x_{21}x_{23} \\ x_{12}x_{11}+x_{22}x_{21} & x_{12}^2+x_{22}^2 & x_{12}x_{13}+x_{22}x_{23} \\ x_{13}x_{11}+x_{23}x_{21} & x_{13}x_{12}+x_{23}x_{22} & x_{13}^2+x_{23}^2 \end{array} \right)\) 也是一個對稱矩陣。
且,他們的跡(trace)也是一樣的,均爲 \(X\) 各個成分的平方和: \[tr(XX^t)=tr(X^tX)=x_{11}^2+x_{12}^2+x_{13}^2+x_{21}^2+x_{22}^2+x_{23}^2\]
對角矩陣
非對角成分(off-diagonal element)均爲零 \(0\) 的正方形矩陣被稱爲對角矩陣(diagonal matrix)。寫成如下形式:
\[\left( \begin{array}{c} a_{11} & 0 & 0 & \cdots & 0\\ 0 & a_{22} & 0 & \cdots & 0\\ 0 & 0 & a_{33} & \cdots & 0\\ 0 & \cdots & 0 & \ddots & 0\\ 0 & 0 & \cdots & 0 & a_{nn} \end{array} \right)=D_n=\Delta_n\\=diag(a_{11},a_{22},a_{33},\cdots,a_{nn})\]
這樣的矩陣也常把左下部分右上部分的非對角成分用一個大的 \(0\) 來表示: \[ \left( \begin{array}{ccccc} a_{11} \\ & a_{22} & & \Huge0 \\ & & a_{33} \\ & \Huge 0 & & \ddots \\ & & & & a_{nn} \end{array} \right) \]
下面也是一個對角矩陣的例子: \[\left( \begin{array}{c} \sqrt{a_{11}} & 0 & 0 & \cdots & 0\\ 0 & \sqrt{a_{22}} & 0 & \cdots & 0\\ 0 & 0 & \sqrt{a_{33}} & \cdots & 0\\ 0 & \cdots & 0 & \ddots & 0\\ 0 & 0 & \cdots & 0 & \sqrt{a_{nn}} \end{array} \right)=D_n^{\frac{1}{2}}=\Delta_n^{\frac{1}{2}}\\=diag(\sqrt{a_{11}},\sqrt{a_{22}},\sqrt{a_{33}},\cdots,\sqrt{a_{nn}})\]
對角成分也可以是分母非零的分數: \[\left( \begin{array}{c} 1/a_{11} & 0 & 0 & \cdots & 0\\ 0 & 1/a_{22} & 0 & \cdots & 0\\ 0 & 0 & 1/a_{33} & \cdots & 0\\ 0 & \cdots & 0 & \ddots & 0\\ 0 & 0 & \cdots & 0 & 1/a_{nn} \end{array} \right)=D_n^{-1}=\Delta_n^{-1}\\=diag(a_{11}^{-1},a_{22}^{-1},a_{33}^{-1},\cdots,a_{nn}^{-1})\]
當然如下的例子也是對角矩陣,默認根號內爲正: \[\left( \begin{array}{c} \frac{1}{\sqrt{a_{11}}} & 0 & 0 & \cdots & 0\\ 0 & \frac{1}{\sqrt{a_{22}}} & 0 & \cdots & 0\\ 0 & 0 & \frac{1}{\sqrt{a_{33}}} & \cdots & 0\\ 0 & \cdots & 0 & \ddots & 0\\ 0 & 0 & \cdots & 0 & \frac{1}{\sqrt{a_{nn}}} \end{array} \right)=D_n^{-\frac{1}{2}}=\Delta_n^{-\frac{1}{2}}\\=diag(\frac{1}{\sqrt{a_{11}}},\frac{1}{\sqrt{a_{22}}},\frac{1}{\sqrt{a_{33}}},\cdots,\frac{1}{\sqrt{a_{nn}}})\]
當然,上述對角矩陣之間具有這樣的關系:\(D_n^{\frac{1}{2}}D_n^{\frac{1}{2}}=D_n\),\(D_n^{-\frac{1}{2}}D_n^{-\frac{1}{2}}=D_n^{-1}\)。
矩陣 \(A\) 或者向量 \(\underline{x}\) 與對角矩陣 \(D\) 從左向右乘時,\(DA, D\underline{x}\) 的第 \(i\) 行成分是:\(A\) 或 \(\underline{x}\) 的第 \(i\) 行乘以 \(D\) 的第 \((i,i)\) 成分。例如:
\(D=\left( \begin{array}{c} \lambda_1 & 0 & 0\\ 0 & \lambda_2 & 0\\ 0 & 0 & \lambda_3\\ \end{array} \right), A=\left( \begin{array}{c} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3 \\ \end{array} \right),\\ \underline{x}=\left( \begin{array}{c} x_1\\ x_2\\ x_3\\ \end{array} \right)\) 時,\(DA=\left( \begin{array}{c} \lambda_1a_1 & \lambda_1a_2 & \lambda_1a_3 \\ \lambda_2b_1 & \lambda_2b_2 & \lambda_2b_3 \\ \lambda_3c_1 & \lambda_3c_2 & \lambda_3c_3 \\ \end{array} \right) \\ D\underline{x}=\left( \begin{array}{c} \lambda_1x_1\\ \lambda_2x_2\\ \lambda_3x_3\\ \end{array} \right)\)