Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

QBUS1040

Tutorial 2

Semester 2, 2022

Exercise 1:  Transforming between two encodings for Boolean vectors

A Boolean n-vector is one for which all entries are either 0 or 1.  Such vectors are used to encode whether each of n conditions holds, with ai  = 1 meaning that condition i holds.  Another common encoding of the same information uses the two values  −1 and +1 for the entries.   For example the Boolean vector (0, 1, 1, 0) would be written using this alternative encoding as ( −1, +1, +1, − 1). Suppose that x is a Boolean vector with entries that are 0 or 1, and y is a vector encoding the same information using the values −1 and +1. Express y in terms of x using vector notation. Also, express x in terms of y using vector notation.

Exercise 2:  Word count and word count histogram vectors

Suppose the n-vector w is the word count vector associated with a document and dictionary of n words. For simplicity, we will assume that all words in the document appear in the dictionary.

(a) What is 1T w?

(b) What does w282  = 0 mean?

(c)  Let h be the n-vector that gives the histogram of the word counts, i.e., hi  is the fraction of the words in the document that are word i. Use vector notation to express h in terms of w .  (You can assume that the document contains at least one word.)

Exercise 3:  General formula for affine functions

Verify that formula (2.4) in VMLS holds for any affine function f : Rn  → R. You can use the fact that f(x) = aT x + b for some n-vector a and scalar b.

Exercise 4:  Python coding exercise

Using Python,

(a) Without using the numpy package, find xT y for the following data:

(i)  x = (−1.2, 0.0, 3.7, −7.2), y = (4, 3, 2, 1)

(ii)  x = (1, 2, 3, . . . , 9), y = (9, 8, 7, . . . , 1)

(b) find the maximum and minimum entry in a random vector of length 20 and compare your result to the inbuilt max() and min() functions.

Exercise 5:

How many flops does it take to form a linear combination of 100 vectors of length 105   (with 100 nonzero coefficients)?  About how long would this take on a computer capable of carrying out 1 Gflop/s?