# 台灣人工智慧學校(台北)第三期技術領袖培訓班資格考試考古題
參考解答會在選項前以星號(*)標記,不過目前有很多缺漏、有作答的也並不保證一定正確,各位高手可以自行編輯(需登入)更正答案或提供各題詳解。
感謝一同討論解題的各位: 怡中, 劉豐源, yogurt
## Calculus
1. Suppose we have $\sigma (x)=\dfrac{1}{1+e^{-x}}$, find $\dfrac{d\sigma (x)}{dx}$.
($A$) $\sigma(x)^2$ *($B$) $\sigma(x)(1-\sigma(x))$ ($C$) $(1-\sigma(x))^2$ ($D$) $\dfrac{1}{1-\sigma(x)}$ ($E$) None of above
2. Find the $x$-coordinates for local minimum and local maximum of $f(x)=x^5-6x^3-8x+4$.
($A$) Doesn't have one ($B$) $(2,-2,1,-1)$ ($C$) $(\dfrac{2}{5},-2,1)$ *($D$) $(2,-2)$ ($E$) None of above
> [Solved by WolframAlpha](http://www.wolframalpha.com/input/?i=d(x%5E5-6x%5E3-8x%2B4)%2Fdx), it has only two real roots $\pm 2$.
3. Suppose that $F(x)=f(g(x)), g(10)=3, g'(10)=9, f(10)=7, f'(3)=5$ and $f'(10)=11$. Find $F'(10)$.
*($A$) $45$ ($B$) $63$ ($C$) $99$ ($D$) $90$ ($E$) None of above
> $F'(x)=f'(g(x))g'(x)$, $F'(10)=f'(g(10))g'(10)=f'(3)*9=45$
4. If we have $f(w,b)=e^{3w+2b}$, find $\dfrac{d^2f(0,0)}{dw^2}+\dfrac{d^2f(0,0)}{db^2}+\dfrac{d^2f(0,0)}{dwdb}$
($A$) $13$ ($B$) $20$ ($C$) $15$ ($D$) $18$ *($E$) None of above
5. $f(x,y)=y^2x^3-y$, find $f_x(2,3)$.
*($A$) $108$ ($B$) $105$ ($C$) $72$ ($D$) $69$ ($E$) None of above
> $f_x=3y^2x^2$, $f_x(2,3)=3*3^2*2^2=108$
## Linear Algebra
6. For the matrices $X=\begin{bmatrix}
1 & 2 & 1 \\
1 & 0 & -2\\
\end{bmatrix}$ and $W=\begin{bmatrix}
-1 & 2 \\
0 & 1\\
3 & -1\\
\end{bmatrix}$, find the product $(XW)^T$.
*($A$) $\begin{bmatrix}
2 & -7 \\
3 & 4\\
\end{bmatrix}$
($B$) $\begin{bmatrix}
2 & 3 \\
-7 & 4\\
\end{bmatrix}$
($C$) $\begin{bmatrix}
1 & 1 & 2 \\
-2 & 0 & 6 \\
-5 & -2 & 1 \\
\end{bmatrix}$
($D$) $\begin{bmatrix}
1 & -2 & -5 \\
1 & 0 & -2 \\
2 & 6 & 1 \\
\end{bmatrix}$
($E$) None of above
>$(XW)^T=W^TX^T=\begin{bmatrix}
2 & -7 \\
3 & 4\\
\end{bmatrix}$
7. Find the Euclidean distance & dot product of $u=(4,1,2)$ and $v=(1,5,2)$.
*($A$) distance=$5$, dot product=$13$
($B$) distance=$6$, dot product=$13$
($C$) distance=$5$, dot product=$5$
($D$) distance=$6$, dot product=$5$
($E$) None of above
> $d=\sqrt{(4-1)^2+(1-5)^2+(2-2)^2}=5$
> $u\cdot v=4*1+1*5+2*2=13$
8. An eigenvalue of matrix $A$ is a scalr such that $det(A-\lambda I)=0$. Find the eigenvalues for the matrix $A=\begin{bmatrix}
1 & 2 & -3 \\
0 & -2 & 0 \\
-1 & 6 & 3 \\
\end{bmatrix}$
($A$) $\lambda=0$ ($B$) $\lambda=(-4,-2,0)$ ($C$) $\lambda=(0,2,4)$ *($D$) $\lambda=(-2,0,4)$ ($E$) None of above
9. For $AX=B$, where $A=\begin{bmatrix}
2 & 8 \\
11 & 2 \\
\end{bmatrix}$ and $B=\begin{bmatrix}
1 & 3 \\
2 & -1 \\
\end{bmatrix}$, find $X^{-1}$.
($A$) Not invertible *($B$) $\begin{bmatrix}
5 & 2 \\
-1 & 2 \\
\end{bmatrix}$ ($C$) $\begin{bmatrix}
5 & -1 \\
2 & 2 \\
\end{bmatrix}$ ($D$) $\begin{bmatrix}
1 & 2 \\
-1 & 3 \\
\end{bmatrix}$ ($E$) None of above
>$X^{-1}=B^{-1}A=\dfrac{1}{-7}\begin{bmatrix}
-1 & -3 \\
-2 & 4 \\
\end{bmatrix}\begin{bmatrix}
2 & 8 \\
11 & 2 \\
\end{bmatrix}=\begin{bmatrix}
5 & 2 \\
-1 & 2\\
\end{bmatrix}$
10. If $A, B, C$ are all $n \times n$ matrices and invertible, which property of matrix operation below is false?
($A$) $A(BC)=(AB)C$
($B$) $A+(B+C)=(A+B)+C$
($C$) $(A+B)C=AC+BC$
($D$) $AA^{-1}=I$
*($E$) None of above
## Statistics & Probability
11. A survey of a group's viewing habits over the last year revealed the following information: (i) 30% watched gymnastics (ii) 30% watched baseball (iii) 20% watched soccer (iv) 14% watched gymnastics and baseball (v) 12% watched baseball and soccer (vi) 10% watched gymnastics and soccer (vii) 8% watched all three sports. Calculate the percentage of the group that watched none of the three sports during the last year.
($A$) $24$% ($B$) $36$% *($C$) $48$% ($D$) $41$% ($E$) None of above
>$P(A)=0.3$,$P(B)=0.3$,$P(C)=0.2$
>$P[A \cap B]=0.14$,$P[B \cap C]=0.12$,$P[A \cap C]=0.1$
>$P[A \cap B \cap C]=0.08$
>$P[(A \cup B \cup C)']$ =1- $P[A \cup B \cup C]$
>=1- $P[A \cup B \cup C]$
>=1-($P(A)$+$P(B)$+$P(C)$-$P[A \cap B]$-$P[B \cap C]$-$P[A \cap C]$+$P[A \cap B \cap C]$)
>=1-0.3-0.3-0.2+0.14+0.12+0.1-0.08
>=0.48
12. You are given $P[A \cup B]=0.6$ and $P[A\cup B']=0.8$. Calculate $P[A]$.
($A$) $0.2$ ($B$) $0.3$ *($C$) $0.4$ ($D$) $0.6$ ($E$) None of above
>$P[A \cup B]=P[A]+P[B-A]=0.6$
>$P[A \cup B']=P[A]+P[B'-A]=0.8$
>$P[A]+P[B-A]+P[A]+P[B'-A]=0.6+0.8$
>$(P[A]+P[B-A]+P[B'-A])+P[A]=1.4$
>$1+P[A]=1.4$
>$P[A]=0.4$
13. Nelson is studying the relationship between blood pressure and heartbeat abnormalities in his patients. He tests a random sample of his patients and notes their blood pressures (high, low, or normal) and their heartbeats (regular or irregular). He finds that: (i) 16% have high blood pressure. (ii) 20% have low blood pressure. (iii) 15% have an irregular heartbeat. (iv) Of those with an irregular heartbeat, one-third have high blood pressure. (v) Of those with normal blood pressure, one-eighth have an irregular heartbeat. Calculate the portion of the patients selected who have a regular heartbeat and low blood pressure.
($A$) $20%$ *($B$) $18%$ ($C$) $8%$ ($D$) $5%$ ($E$) None of above
14. An auto insurance company insures drivers of all ages. Jimmy compiled the following statistics on the company's insured drivers:
| Age of Driver | Probability of Accident | Portion of Company's Insured Drivers |
|:-:|:-:|:-:|
|16-20|0.06|0.08|
|21-30|0.03|0.15|
|31-65|0.02|0.49|
|66-99|0.04|0.28|
A randomly selected driver that the company insures has an accident. Calculate the probabilty that the driver was age 21-30.
($A$) $0.13$ ($B$) $0.16$ ($C$) $0.19$ ($D$) $0.23$ *($E$) None of above
>$0.03*0.15/(0.06*0.08+0.03*0.15+0.02*0.49+0.04*0.28) =0.1485$
15. The dotplot below shows the number of televisions owned by each family on a city block.

($A$) The distribution is left-skewed with no outlier.
*($B$) The distribution is right-skewed with no outliers.
($C$) The distribution is left-skewed with many outliers.
($D$) The distribution is right-skewed with many outliers.
($E$) None of above
16. The number of injury claims per month is modeled by a random variable $N$ with $P[N=n]=\dfrac{1}{(n+1)(n+2)}$, for non-negative integers, $n$. Calculate the probability of at least two claim during a particular month, given that there have been at most four claims during that month.
($A$) $\dfrac{1}{3}$ *($B$) $\dfrac{1}{5}$ ($C$) $\dfrac{2}{3}$ ($D$) $\dfrac{2}{5}$ ($E$) None of above
> $\dfrac{P(2)+P(3)+P(4)}{P(0)+P(1)+P(2)+P(3)+P(4)} = \dfrac{1}{5}$
17. About 2% of alumni give money upon receiving a solicitation from the college or university from which they graduated. Find the average number monetary gifts a college can expect from every 2000 solicitations it sends.
($A$) $4$ ($B$) $20$ *($C$) $40$ ($D$) $80$ ($E$) None of above
> 2%*2000 = 40 (expection, 期望值)
18. Four friends take an IQ test. Their scores are $96,100,106,114$ Which of the following statements are true?
($A$) The mean is $103$, the median is $100$
($B$) The mean is $103$, the median is $106$
*($C$) The mean is $104$, the median is $103$
($D$) The mean is $104$, the median is $100$
($E$) None of the above
> $mean =\dfrac{96 + 100 + 106 + 114}{4}=104$
> $median =\dfrac{100 + 106}{2}=103$
19. Assume the $P(A)=0.5$ and $P(B)=0.3$. If $A$ and $B$ are mutually exclusive, what is $P(A$ or $B)$?
($A$) $0.58$ ($B$) $0.7$ *($C$) $0.8$ ($D$) $0.88$ ($E$) None of above
> Mutually Exclusive: $P(A\cap B) =0$
> $P(A \cup B) =P(A)+P(B)-P(A\cap B)=0.5+0.3-0=0.8$
20. An AI Academy test is administered seasonally to AI enthusiast. The test has a mean score of 60 and a standard deviation of 18. If Felix's z-score is 1.2, what was his score on the test?
($A$) $62$ ($B$) $68.8$ ($C$) $80$ *($D$) $81.6$ ($E$) None of above
> Please see the introduction of [Standard Score (z-score)](https://en.wikipedia.org/wiki/Standard_score).
> $z = \dfrac{x-u}{\sigma}=\dfrac{x-60}{18}=1.2$
> $\Rightarrow x=81.6$
## Programming Section
There are three questions here, and each of them has a different score assign to them (6, 8, 6) with a total score of 20. The questions should be answered with pseudocode.
Pseudocode is a simple way of writing programming code in English. Pseudocode is not actual programming language. It uses short phrases to write code for programs before you actually create it in a specific language. The purpose of using pseudocode is that it is easier for people to understand the logic behind the algorithms.
Rules for pseudo code:
1. Write one statement per line.
2. Any words after # are comments
3. Available keywords: IF, ENDIF, ELSE, WHILE, ENDWHILE, BREAK, APPEND, FUNCTION, FOR, PRINT, LENGTH, INT,
RETURN, LIST()
4. Avaliable operations: + - * / = == != <= >=
**Question 1**
Write a function and named it "MinMaxScaler". The function should scale a set of numbers down to a range in between 0 and 1. As the function name suggested, we will be using the min-max-scaler to complete this task (6 points total). You are given an array called "data".
Example: `data = [4, 9, 3, 10, 0, 2]`
**1-1**
Write a function and named it "Min". The function should be return the minimum value of an array (2 points).
Goal:
$\quad$Input: Min(data)
$\quad$Output: Minimum of data
$\quad$Output for example: 0
```
funciton Min(data){
var min <- data[0];
for (i from 1 to (length(data)-1)){
if (min > data[i]){
min <- data[i];
}
}
return min;
}
```
**1-2**
Write a function and named it "Max". The function should be return the maximum value of an array (2 points).
Goal:
$\quad$Input: Max(data)
$\quad$Output: Maximum of data
$\quad$Output for example: 10
```
funciton Max(data){
var max <- data[0];
for (i from 1 to (length(data)-1)){
if (min < data[i]){
min <- data[i];
}
}
return max;
}
```
**1-3**
Using the equation below and the two functions we just wrote to complete `MinMaxScaler` (2 points).
$$Scaled \text{ } data=\dfrac{X-Min}{Max-Min}$$
Goal:
$\quad$Input: MinMaxScaler(data)
$\quad$Output: Scaled data
$\quad$Output for example: `[0.4, 0.9, 0.3, 1, 0, 0.2]`
```
funciton MinMaxScaler(data){
var max <- Max(data);
var min <- Min(data);
for (i from 0 to (length(data)-1)){
data[i] <- (data[i] - min) / (max - min);
}
return data;
}
```
**Question 2**
Debug (8 points total): Steven was given a list of grades (called grades here) from an exam, and he intended to return another list (called status here) that indicated whether the students passed the exam or not. However he made four mistakes in his function. Rewrite the code indicated so that the function can run smoothlly (2 points each)
Append: Append is a function that insert an item to the end of a list, for example, if we have a list called `T` that contains `[1,2,3,4]`, then if we do `T.append(6)` then the list T will be `[1,2,3,4,6]`
```
1 function PassFail(grades){
2 #A student pass when his or her grade is grater than or equal to 60
3
4 if (grade is NULL):
5 return False
6
7 start = 0
8 end = length(grades) - 1
9 status = 0
10
11 while (start < end){
12 if (grades[start] > 60):
13 status.append('Pass')
14 else:
15 status.append('Fail')
16
17 start + 1
18 }
19
20 return False
21 }
```
Goal:
$\quad$Sample input: `PassFail([20, 80, 59, 60])`
$\quad$Expected output: `[Fail, Pass, Fail, Pass]`
> **Line 9**:
> status = []
> **Line 12**:
> if (grades[start] >= 60):
> **Line 17**:
> start += 1
> **Line 20**:
> return status
**Question 3**
Write a function and named it `MagicSquare` that determined if a $3 \times 3$ matrix is a magic square or not. A magic square is a square matrix which all rows, columns, and diagonals summed up to be the same (shown below). You are given a matrix called data. (6 points total)

You can access a specific element by doing `data[i][j]` where the first bracket represents the row number and the second bracket represents the column number. For example, `data[1][2]` will return 1 using the square matrix above (we started counting from 0, so 1 would be the second rows/columns, 2 would be the third rows/columns).
**3-1**
Write a function and named it `row_sum_check`, it shoud check whether all sums of the rows are equivalent or not using for loops (1 points).
Goal:
$\quad$Input: `row_sum_check(data)`
$\quad$Output: Either `True` or `False`
```
function row_sum_check(data)
{
sum[]=0
for i from 0 to 2
for j from 0 to 2
{
sum[i] += data[i][j]
if(i != 0)
if(sum[i] != sum[i-1])
return false
}
return true
}
```
**3-2**
Write a function and named it `column_sum_check`, it shoud check whether all sums of the columns are equivalent or not using for loops (1 points).
Goal:
$\quad$Input: `column_sum_check(data)`
$\quad$Output: Either `True` or `False`
```
function column_sum_check(data)
{
sum[]=0
for j from 0 to 2
for i from 0 to 2
{
sum[i] += data[i][j]
if(i != 0)
if(sum[i] != sum[i-1])
return false
}
return true
}
```
**3-3**
Write a function and named it `diagonal_sum_check`, it shoud check whether all sums of the diagonals are equivalent or not using for loops (1 points).
Goal:
$\quad$Input: `diagonal_sum_check(data)`
$\quad$Output: Either `True` or `False`
```
function diagonal_sum_check(data)
{
D1 = 0
D2 = 0
for i from 0 to 2
{
D1 += data[i][i]
D2 += data[i][2-i]
}
if(D1 != D2)
return false
return true
}
```
**3-4**
Complete the function `MagicSquare` where the function returns either True or False using the functions we wrote above (3 points).
Goal:
$\quad$Input: `MagicSquare(data)`
$\quad$Output: Either `True` or `False`
```
function MagicSquare(data)
{
status1 = row_sum_check(data)
status2 = column_sum_check(data)
status3 = diagonal_sum_check(data)
if(status1 & status2 & status3)
return ture
return false
}
```