Homework 1: Background Test: Due 12 A.M. Tuesday, September 06, 2020
Homework 1: Background Test: Due 12 A.M. Tuesday, September 06, 2020
Homework 1: Background Test: Due 12 A.M. Tuesday, September 06, 2020
• Instructions
• Submit your homework by sending a PDF file into Courseware by 12 a.m. Tuesday, September 06, 2020
with the following format into its title: “Your Full Name; Your Student Number, Your Email”.
• Late homework policy: Homework is worth full credit if submitted before the due date, half credit
during the next 48 hours, and zero credit afterward.
• Collaboration policy: For this homework only, you are welcome to collaborate on any of the questions
with anybody you like. However, you must write up your own final solution, and you must list the names
of anybody you collaborated with on this assignment. The point of this homework is not really for us
to evaluate you, but instead for you to determine whether you have the right background for this class,
and to fill in any gaps you may have.
1
Homework 1: Background Test 52795 Machine Learning with Graphs.
2 4 1 2
X=[ ] y=[ ] z=[ ]
1 3 3 3
1. What is the inner product of the vectors y and z? (this is also sometimes called the, and is
sometimes written yTz)
2. What is the product Xy?
3. Is X invertible? If so, give the inverse, and if no, explain why not.
4. What is the rank of X?
Consider a sample of data S = {1, 1, 0, 1, 0} created by flipping a coin x five times, where 0 denotes that the coin
turned up heads and 1 denotes that it turned up tails.
3. What is the probability of observing this data, assuming it was generated by flipping a coin
with an equal probability of heads and tails (i.e. the probability distribution is p(x = 1) = 0.5,
p(x = 0) = 0.5).
4. Note that the probability of this data sample would be greater if the value of p(x = 1) was
not 0.5, but instead some other value. What is the value that maximizes the probability of
the sample S. Please justify your answer.
3
Plugging in our values for x1, . . . , x5 into the above formula, we find that the best p = 5.
2
Homework 1: Background Test 52795 Machine Learning with Graphs.
5. Consider the following joint probability table over variables y and z, where y takes a value
from the set {a,b,c}, and z takes a value from the set {T,F}:
y
a b C
z
T 0.2 0.1 0.2
F 0.05 0.15 0.3
• What is p(z = T AND y = b)?
• What is p(z = T|y = b)?
For each pair (f, g) of functions below, list which of the following are true: f (n) = O(g(n)), g(n) = O(f(n)),
or both. Briefly justify your answers.
3
Homework 1: Background Test 52795 Machine Learning with Graphs.
Algorithms [5 Points]
Divide and Conquer: Assume that you are given an array with n elements all entries equal either to 0 or +1 such
that all 0 entries appear before +1 entries. You need to find the index where the transition happens, i.e. you
need to report the index with the last occurrence of 0.
Give an algorithm that runs in time O(log n). Explain your algorithm in words, describe why the algorithm is
correct, and justify its running time.
Probability
State true or false. Here Ac denotes complement of the event A.
1. P (A ∪ B) = P (A ∩ (B ∩ Ac))
2. P (A ∪ B) = P (A) + P (B) − P (A ∩ B)
3. P (A) = P (A ∩ B) + P (Ac ∩ B)
4. P (A|B) = P (B|A)
5. P (A1 ∩ A2 ∩ A3) = P (A3|(A2 ∩ A1))P (A2|A1)P (A1)