Try   HackMD

台灣人工智慧學校(台北)第三期技術領袖培訓班資格考試考古題

參考解答會在選項前以星號(*)標記,不過目前有很多缺漏、有作答的也並不保證一定正確,各位高手可以自行編輯(需登入)更正答案或提供各題詳解。

感謝一同討論解題的各位: 怡中, 劉豐源, yogurt

Calculus

  1. Suppose we have

    σ(x)=11+ex, find
    dσ(x)dx
    .
    (
    A
    )
    σ(x)2
    *(
    B
    )
    σ(x)(1σ(x))
    (
    C
    )
    (1σ(x))2
    (
    D
    )
    11σ(x)
    (
    E
    ) None of above

  2. Find the

    x-coordinates for local minimum and local maximum of
    f(x)=x56x38x+4
    .
    (
    A
    ) Doesn't have one (
    B
    )
    (2,2,1,1)
    (
    C
    )
    (25,2,1)
    *(
    D
    )
    (2,2)
    (
    E
    ) None of above

Solved by WolframAlpha, it has only two real roots

±2.

  1. 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

  1. If we have

    f(w,b)=e3w+2b, find
    d2f(0,0)dw2+d2f(0,0)db2+d2f(0,0)dwdb

    (
    A
    )
    13
    (
    B
    )
    20
    (
    C
    )
    15
    (
    D
    )
    18
    *(
    E
    ) None of above

  2. f(x,y)=y2x3y, find
    fx(2,3)
    .
    *(
    A
    )
    108
    (
    B
    )
    105
    (
    C
    )
    72
    (
    D
    )
    69
    (
    E
    ) None of above

fx=3y2x2,
fx(2,3)=33222=108

Linear Algebra

  1. For the matrices
    X=[121102]
    and
    W=[120131]
    , find the product
    (XW)T
    .
    *(
    A
    )
    [2734]

    (
    B
    )
    [2374]

    (
    C
    )
    [112206521]

    (
    D
    )
    [125102261]

    (
    E
    ) None of above

(XW)T=WTXT=[2734]

  1. 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=(41)2+(15)2+(22)2=5
uv=41+15+22=13

  1. An eigenvalue of matrix

    A is a scalr such that
    det(AλI)=0
    . Find the eigenvalues for the matrix
    A=[123020163]

    (
    A
    )
    λ=0
    (
    B
    )
    λ=(4,2,0)
    (
    C
    )
    λ=(0,2,4)
    *(
    D
    )
    λ=(2,0,4)
    (
    E
    ) None of above

  2. For

    AX=B, where
    A=[28112]
    and
    B=[1321]
    , find
    X1
    .
    (
    A
    ) Not invertible *(
    B
    )
    [5212]
    (
    C
    )
    [5122]
    (
    D
    )
    [1213]
    (
    E
    ) None of above

X1=B1A=17[1324][28112]=[5212]

  1. If
    A,B,C
    are all
    n×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
    )
    AA1=I

    *(
    E
    ) None of above

Statistics & Probability

  1. 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[AB]=0.14
,
P[BC]=0.12
,
P[AC]=0.1

P[ABC]=0.08

P[(ABC)]
=1-
P[ABC]

=1-
P[ABC]

=1-(
P(A)
+
P(B)
+
P(C)
-
P[AB]
-
P[BC]
-
P[AC]
+
P[ABC]
)
=1-0.3-0.3-0.2+0.14+0.12+0.1-0.08
=0.48

  1. You are given
    P[AB]=0.6
    and
    P[AB]=0.8
    . Calculate
    P[A]
    .
    (
    A
    )
    0.2
    (
    B
    )
    0.3
    *(
    C
    )
    0.4
    (
    D
    )
    0.6
    (
    E
    ) None of above

P[AB]=P[A]+P[BA]=0.6
P[AB]=P[A]+P[BA]=0.8

P[A]+P[BA]+P[A]+P[BA]=0.6+0.8

(P[A]+P[BA]+P[BA])+P[A]=1.4

1+P[A]=1.4

P[A]=0.4

  1. 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

  2. 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.030.15/(0.060.08+0.030.15+0.020.49+0.040.28)=0.1485

  1. The dotplot below shows the number of televisions owned by each family on a city block.

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

    (
    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

  2. The number of injury claims per month is modeled by a random variable

    N with
    P[N=n]=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
    )
    13
    *(
    B
    )
    15
    (
    C
    )
    23
    (
    D
    )
    25
    (
    E
    ) None of above

P(2)+P(3)+P(4)P(0)+P(1)+P(2)+P(3)+P(4)=15

  1. 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, 期望值)

  1. 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=96+100+106+1144=104
median=100+1062=103

  1. 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(AB)=0
P(AB)=P(A)+P(B)P(AB)=0.5+0.30=0.8

  1. 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).

z=xuσ=x6018=1.2
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:

Input: Min(data)
Output: Minimum of data
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:

Input: Max(data)
Output: Maximum of data
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 data=XMinMaxMin
Goal:
Input: MinMaxScaler(data)
Output: Scaled data
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:

Sample input: PassFail([20, 80, 59, 60])
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×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:

Input: row_sum_check(data)
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:

Input: column_sum_check(data)
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:

Input: diagonal_sum_check(data)
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:

Input: MagicSquare(data)
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
}