「統計解析のための線形代数」復習筆記3
函數的最大值最小值問題
沒有制約條件的情況
函數 \(F(a_1,a_2,\dots,a_i,\dots,a_n)\) 取最大值或者最小值時,以下的連立方程 \[\frac{\partial F}{\partial a_1}=0,\frac{\partial F}{\partial a_2}=0,\frac{\partial F}{\partial a_3}=0, \dots,\frac{\partial F}{\partial a_i}=0, \dots, \frac{\partial F}{\partial a_n}=0\] 要成立(必要條件)。
1.已知下列方程有最小值,求當該方程取最小值時\(a_1,a_2\)的值 \[F(a_1,a_2)=\left\{y_1-(a_1+a_2x_1)\right\}^2+\left\{y_2-(a_1+a_2x_2)\right\}^2+\cdots+\left\{y_n-(a_1+a_2x_n)\right\}^2\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;=\sum\limits_{i=1}^n\left\{y_i-(a_1+a_2x_i)\right\}^2\\\]
\[\begin{align} \frac{\partial F}{\partial a_1}&=-2\left\{y_1-(a_1+a_2x_1)\right\}-2\left\{y_2-(a_1+a_2x_2)\right\}-\cdots-2\left\{y_n-(a_1+a_2x_n)\right\}\\ &= -2\sum_{i=1}^n\left\{y_i-(a_1+a_2x_i)\right\}=0 \Leftrightarrow \sum_{i=1}^n\left\{y_i-(a_1+a_2x_i)\right\}=0\\ \Leftrightarrow \sum_{i=1}^ny_i &= a_1\cdot n+a_2\sum_{i=1}^nx_i (1)\\ \\ \frac{\partial F}{\partial a_2}&=-2x_1\left\{y_1-(a_1+a_2x_1)\right\}-2x_2\left\{y_2-(a_1+a_2x_2)\right\}-\cdots-2x_3\left\{y_n-(a_1+a_2x_n)\right\}\\ &= -2\sum_{i=1}^nx_i\left\{y_i-(a_1+a_2x_i)\right\}=0\\ \Leftrightarrow \sum_{i=1}^nx_iy_i &=a_1\sum_{i=1}^nx_i+a_2\sum_{i=1}^nx_i^2 (2)\\ &將(1)(2)連立方程求解即可。在回歸分析中,\\ &這個連立方程組被稱作正規方程組(Normal \;equation) \end{align}\]
- 求下列方程取最大或者最小值時的\(a_1,a_2,a_3\)的大小: \[F(a_1,a_2,a_3)=a_1^2+a_1a_2+a_1a_3+a_2^2+a_2a_3+a_3^2-6a_1-3a_2-7a_3\]
\[\begin{align} 解連立方程:\\ \frac{\partial F}{\partial a_1} & = 2a_1+a_2+a_3-6=0\\ \frac{\partial F}{\partial a_2} & = a_1+2a_2+a_3-3=0\\ \frac{\partial F}{\partial a_3} & = a_1+a_2+2a_3-7=0\\ 答:& a_1=2, a_2=-1,a_3=3 \end{align}\]