# 台灣人工智慧學校(台北)第二期技術領袖培訓班資格考試考古題 參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)更正答案或提供各題詳解。 感謝**Anio俊傑**提供題目和一同討論解題的各位: **Sean, Moony Hsieh, johnson, 怡中, Jacky Chang, Aellen, Yvon Wong, Victor Lin** ## Calculus 1. $f(w,b)=e^{-(2w+b)}$, find $\dfrac{\partial f(w,b)}{\partial w}$ at $w=1$, $b=-2$ ($A$) $2$ ($B$) $1$ ($C$) $e^{-2}$ *($D$) $-2$ ($E$) $-e^{-1}$ >$\dfrac{\partial f(w,b)}{\partial w}=e^{(-2w-b)}*(-2)$ $\dfrac{\partial f(1,-2)}{\partial w}=e^{0}*(-2)=-2$ 2. Estimate the extreme values (local minimum and local maximum) respectively, of the function $f(x)=-2x^3-3x^2+12x$ *($A$) $-20,7$ ($B$) $0,7$ ($C$) $-5,20$ ($D$) $-4,-223$ ($E$) $-13,5$ >$f'(x)=-6x^2-6x+12=-6(x+2)(x-1)$ extreme values occur at $x=-2$ or $1$ $f(-2)=-20$, $f(1)=7$ 3. If $f(y)=2y$, where $y(x)=x^3+3x$, find $\dfrac{df}{dx}$ at $x=5$. ($A$) $78$ ($B$) $2$ ($C$) $0$ ($D$) $280$ *($E$) None of above >$\dfrac{\partial f}{\partial x}=\dfrac{\partial}{\partial x} (2x^3+6x)=6x^2+6$ $\dfrac{\partial f(5)}{\partial x}=156$ 4. Suppose $0\leq x\leq 1$. Find $x$ such that $f(x)=-x\log_2 x-(1-x)\log_2(1-x)$ is maximized. ($A$) $0$ *($B$) $0.5$ ($C$) $1$ ($D$) $0.25$ ($E$) $0.75$ >$f'(x)=-\log x-1+\log (1-x)+1=\log (1-x)-\log x$ maxima occurs at $f'(x)=0$, thus $x=0.5$ 5. A function $f(x,y)=ax^2+2bxy+cy^2$ is built with real numbers $a$, $b$, and $c$. In which conditions it will be guranteed to have a saddle point at $(x,y)=(0,0)$? ($A$) $a>0,ac>b^2$ ($B$) $a<0,ac>b^2$ *($C$) $ac<b^2$ ($D$) $ac>0$ ($E$) None of above >$f(x,y)=ax^2+2bxy+cy^2$ $f_{xx}=2a$, $f_{xy}=f_{yx}=2b$, $f_{yy}=2c$ Hessian $H(x,y)=\begin{bmatrix} 2a & 2b \\ 2b & 2c \\ \end{bmatrix}$ > >criteria for saddle point: $det(H(x,y))<0$ $ac-b^2<0$ > >Saddle point info > [http://calculus.yuyumagic424.net/wp-content/uploads/2013/03/%E5%A4%9A%E8%AE%8A%E5%87%BD%E6%95%B8%E7%9A%84%E6%A5%B5%E5%80%BC.pdf](https://) ## Linear Algebra 6. For the matrices $X=\begin{bmatrix} 1 & 0 & -2 \\ 3 & -2 & -1\\ \end{bmatrix}$ and $W=\begin{bmatrix} 1 & 2 \\ 9 & 0\\ 1 & 2\\ \end{bmatrix}$, find the product $(XW)^T$. ($A$) $\begin{bmatrix} 1 & -2 \\ 18 & 6\\ \end{bmatrix}$ *($B$) $\begin{bmatrix} -1 & -16 \\ -2 & 4\\ \end{bmatrix}$ ($C$) $\begin{bmatrix} 7 & 9 & 7 \\ -4 & 0 & -4 \\ -4 & -18 & -4 \\ \end{bmatrix}$ ($D$) $\begin{bmatrix} 7 & -4 & -4 \\ 9 & 0 & -18 \\ 7 & -4 & -4 \\ \end{bmatrix}$ ($E$) None of above >$(XW)^T=W^TX^T=\begin{bmatrix} -1 & -16 \\ -2 & 4 \\ \end{bmatrix}$ 7. An eigenvalue of matrix $A$ is a scalar $\lambda$ such that $det(\lambda I-A)=0$. Find the eigenvalues for the matrix $A=\begin{bmatrix} 1 & 2 & 1 \\ 6 & -1 & 0 \\ -1 & -2 & -1 \\ \end{bmatrix}$ ($A$) $\lambda =-3,0,2$ ($B$) $\lambda=3,1,4$ ($C$) $\lambda=-2,0,1$ *($D$) $\lambda=3,0,-4$ ($E$) $\lambda=-4,-1,2$ >$det(A-\lambda I)=-\lambda^3-\lambda^2+12\lambda=\lambda(\lambda-3)(\lambda+4)$ $\lambda=0,3,-4$ 8. For $AX=B$, where $A=\begin{bmatrix} 1 & 2 \\ 2 & -1 \\ \end{bmatrix}$ and $B=\begin{bmatrix} -1 & 1 \\ -12 & 7 \\ \end{bmatrix}$, find $X^{-1}$. *($A$) $\begin{bmatrix} 1 & 3 \\ 2 & 5 \\ \end{bmatrix}$ ($B$) $\begin{bmatrix} -25 & 15 \\ 10 & -5 \\ \end{bmatrix}$ ($C$) $\begin{bmatrix} -1 & -2 \\ -2 & 1 \\ \end{bmatrix}$ ($D$) $\begin{bmatrix} -5 & -3 \\ -2 & -1 \\ \end{bmatrix}$ ($E$) $\begin{bmatrix} 7 & -1 \\ 12 & 1 \\ \end{bmatrix}$ >$X^{-1}=B^{-1}A=\begin{bmatrix} 1 & 3 \\ 2 & 5 \\ \end{bmatrix}$ 9. Given two vectors $\vec{u}=(1,0,-2)$ and $\vec{v}=(2,1.5,1)$, find the $L^2$ norm (Euclidean distance) $\vec{v}-\vec{u}$ and the angle between them. ($A$) distance=$1$, angle=$30^{\circ}$ ($B$) distance=$1.5$, angle=$60^{\circ}$ ($C$) distance=$2$, angle=$75^{\circ}$ ($D$) distance=$2.5$, angle=$45^{\circ}$ *($E$) distance=$3.5$, angle=$90^{\circ}$ >$d=\sqrt{(2-1)^2+(1.5-0)^2+(1-(-2))^2}=3.5$ $\theta = \cos^{-1}(\dfrac{u\cdot v}{\vert u\vert \vert v\vert})= \cos^{-1}(0)=\dfrac{\pi}{2}$ 10. For which values of $a$ are there no solutions, many solutions, or a unique solution to the system given below? $x+y=1$ $6x+6y=a$ ($A$) $a=6$, $a\neq 6$, none ($B$) $a\neq 6$, none, $a=6$ *($C$) $a\neq 6$, $a=6$, none ($D$) $a=6$, none, $a\neq 6$ ($E$) none, $a\neq 6$, $a=6$ >$x+y=a/6$ no solution: $a/6 \neq 1$ infinite solutions: $a/6 = 1$ no solution: none ## Statistics & Probability 11. Given $P(A)=0.25$, $P(B)=0.5$, $P(A \vert B)=0.1$, what is $P(B \vert A)$? ($A$) $0.16$ *($B$) $0.2$ ($C$) $0.55$ ($D$) $0.65$ ($E$) $0.74$ >$0.1*0.5/0.25=0.2$ 12. Assume that $P(A)=0.4$ and $P(B)=0.3$. If $A$ and $B$ are mutually exclusive, what is $P(A$ or $B)$? *($A$) $0.7$ ($B$) $0.58$ ($C$) $0.88$ ($D$) $0.1$ ($E$) None of above >$0.3+0.4=0.7$ 13. Suppose a random experiment has the following characteristics. (1) There are $n$ identical and independent trials of a common procedure. (2) There are exactly two possible outcomes for each trial, one termed "success" and the other "failure." (3) The probability of success on any one trial is the same number $q$. We also say that $X$ has a binomial distribution with parameters $n$ and $q$. As we know, $Var(X)=nq(1-q)$. Find $E(X^2)$. Hint: $E(X^2)=E(X-\mu+\mu)^2=E(X-\mu)^2-2E[(X-\mu)\mu]+E(\mu^2)=...$ ($A$) $nq^2+nq(n+1)$ *($B$) $nq+nq^2(n-1)$ ($C$) $nq-nq^2(n-1)$ ($D$) $nq+nq^2(n-1)$ ($E$) $nq^2-nq(n-1)$ 14. Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice? *($A$) Yes ($B$) No ($C$)Switching or not will not change the winning probability. > Please see the introduction of [Monty Hall problem](https://en.wikipedia.org/wiki/Monty_Hall_problem) or this Chinese [post](https://m.gamer.com.tw/home/creationDetail.php?sn=3204111) with illustrative example. 15. Which of the following statements are true? I. All variables can be classified as quantitative or categorical variables. II. Categorical variables can be continuous variables. III. Quantitative variables can be discrete variables. ($A$) I only ($B$) II only ($C$) III only ($D$) I and II *($E$) I and III According to the chart, which of the following statements are true? 16. The dotplot below shows the number of televisions owned by each family on a city block. ![](https://i.imgur.com/bCZf4HP.jpg) *($A$) The distribution is right-skewed with no outlier. ($B$) The distribution is right-skewed with many outliers. ($C$) The distribution is left-skewed with no outliers. ($D$) The distribution is left-skewed with many outliers. ($E$) The distribution is symmetric. 17. A national achievement test is administered annually to 3rd graders. The test has a mean score of 80 and a standard deviation of 15. If Jane's z-score is $-1.20$, what was her score on the test? *($A$) 62 ($B$) 68 ($C$) 85 ($D$) 92 ($E$) 98 >$z=\dfrac{x-\mu}{\sigma}$, $-1.2=\dfrac{x-80}{15}$ $x=62$ 18. When we are fitting the regression model, we usually use sum of the squared error to evaluate our regression model. This number measures the goodness of fit of the line to the data. In this case, a regression model has a lower sum of the squared error and it's better model for our dataset. | | Data1 |Data2|Data3|Data4|Data5| |:-:|:-:|:-:|:-:|:-:|:-:| |x|2|2|6|8|0| |y|0|1|2|3|3| Which of the models shown below is the best one, having a minimal squared error? ($A$) $\hat{y}=0.35x-0.125$ ($B$) $\hat{y}=-0.35x+0.125$ ($C$) $\hat{y}=0.65x-0.45$ ($D$) $\hat{y}=-0.6x-0.125$ *($E$) $\hat{y}=0.35x+0.55$ >Squared error of 5 models: 10.383125, 59.083125, 17.8125, 112.508125, 8.1725 19. Which of the following statements are true? I. When the sum of the residuals is greater than zero, the dataset is nonlinear. II. A random pattern of residuals supports a linear model. III. A random pattern of residuals supports a nonlinear model. ($A$) I only *($B$) II only ($C$) III only ($D$) I and II ($E$) I and III 20. The random variable $Z$ is normally distributed. Mean of $Z$ is $430$, and the value $Z=300$ is the 14th percentile of the distribution. Which is the best estimate of the standard deviation of the distribution. *($A$) 125 ($B$) 135 ($C$) 145 ($D$) 155 ($E$) 165 ## Programming 1. Create a custom function, Derivative(), which can compute the first derivative of a given function $f(x)$ with respect to $x$ via Central Difference Method, defined as $\lim_{h\to 0} \dfrac{f(x+\dfrac{h}{2})-f(x-\dfrac{h}{2})}{h}$. NOTE: Suppose the only available function is `print()` and let us set $h=1.0e-1$. ```python # python參考程式碼 def derivative(f,x,h,order): if order == 0: return f(x) else: return (derivative(f,x+h/2,h,order-1)-derivative(f,x-h/2,h,order-1))/h ``` 2. A Taylor series of a function $g(x)$ around $x=a$ is defined by the following series expansion, $\sum_{n=0}^\infty \dfrac{g^{(n)}(a)}{n!}(x-a)^n$, where $g^{(n)}$ denotes $n^{\text{th}}$ derivative of $g(x)$. Now, given $g(x)=2^x+2x^7$, try to create a custom function, `Taylor_Expansion()`, to compute $g(x=3)$ by using Taylor series ($a=0$) up to $7^{\text{th}}$ order in $n$. You should find that while the answer deviates from the exact solution $g(x=3)$ obtained from a direct substitution, the error is less than $3\%$. HINT: You can take $x=3, a=0$ and keep the summation only up to $n=7$ in the seies formula. NOTE: The only available function is `print()` and the custom function you got in $1.$ is useful. ```python def derivative(f,x,h,order): if order == 0: return f(x) else: return (derivative(f,x+h/2,h,order-1)-derivative(f,x-h/2,h,order-1))/h def factorial(n): if(n<=1): return 1 else: return factorial(n-1) * n def Taylor_Expansion(f,x,a,h,order): ans = 0 for i in range(order+1): ans += derivative(f,a,h,i)*((x-a)**i)/factorial(i) return ans def g(x): return 2**x+2*x**7 h = 0.1 x = 3 a = 0 order = 7 A = g(x) T = Taylor_Expansion(g,x,a,h,order) print(A) # 4382 print(T) # 4424.5478396 ```