ml.lab
Python sleeps until you run code
01 Vectors and the dot product

Checkpoint

Vectors and the dot product

Eleven questions across the whole module: combinations, span and bases, the dot product and projection, length, cosine similarity and Cauchy-Schwarz. The numbers are new, and several questions aim at the classic confusions. Work on paper before answering, and write the code without looking back at the lessons if you can. You need 80% to pass.

  1. 1

    Do u=(1,2,0)\mathbf{u} = (1, 2, 0) and v=(0,1,3)\mathbf{v} = (0, 1, 3) span all of R3\mathbb{R}^3?

  2. 2

    Compute 2 (1,−1,3)−(4,0,5)+3 (0,1,−1)2\,(1, -1, 3) - (4, 0, 5) + 3\,(0, 1, -1).

    result
  3. 3

    In the basis p=(1,1)\mathbf{p} = (1, 1), q=(1,−1)\mathbf{q} = (1, -1), what are the coordinates of the vector (4,1)(4, 1)?

    coordinates in p, q
  4. 4

    Which statement about the vectors (1,2)(1, 2), (3,1)(3, 1) and (4,3)(4, 3) is true?

  5. 5

    Two vectors have lengths ∣a∣=4|\mathbf{a}| = 4 and ∣b∣=5|\mathbf{b}| = 5, and the angle between them is 120°120°. What is a⋅b\mathbf{a}\cdot\mathbf{b}?

    a · b
  6. 6

    Find proj⁡ba\operatorname{proj}_{\mathbf{b}}\mathbf{a} for a=(2,3)\mathbf{a} = (2, 3) and b=(4,−2)\mathbf{b} = (4, -2).

    proj
  7. 7

    Find the cosine similarity of (2,3,6)(2, 3, 6) and (1,4,8)(1, 4, 8), to 3 decimal places.

    cos θ
  8. 8

    Two embeddings have been normalized to length 1, and their cosine similarity is 0.680.68. How far apart are their tips?

    distance
  9. 9

    Vectors a\mathbf{a} and b\mathbf{b} have ∣a∣=2|\mathbf{a}| = 2 and ∣b∣=5|\mathbf{b}| = 5. Which of these values could a⋅b\mathbf{a}\cdot\mathbf{b} take? Select every possible value.

  10. 10

    A search index stores one embedding per document. A bug multiplies one document's vector by 3 and leaves every other vector unchanged. For a fixed query, which rankings could change? Select all that apply.

  11. 11
    Code it

    Write angle_degrees(a, b): the angle between two nonzero vectors, in degrees, from 0 to 180. Raise ValueError if either vector is the zero vector. It must return a real number for every pair of nonzero vectors, parallel ones included.

    ⌘↵ runsPython sleeps until you run code
11 still unanswered. Unanswered questions count as wrong.