Quiz: vectors, dot product & projection
Short questions to test your geometric intuition. Try each on paper first, then open the answer.
Q1. A gene-expression profile of 12 000 genes is a vector. In how many dimensions does it “live”?
The dimension equals the number of components (measurements).
12 000 dimensions — one axis per gene. We cannot draw it, but every rule from 2-D and 3-D still applies.
Q2. Compute \(\begin{pmatrix} 2 \\ -1 \end{pmatrix} + 3\begin{pmatrix} 1 \\ 2 \end{pmatrix}\).
Scale first, then add componentwise.
\(3(1,2) = (3,6)\), then \((2,-1)+(3,6) = (5,\ 5)\).
Q3. What is the length of \(\begin{pmatrix} 6 \\ 8 \end{pmatrix}\)?
For \(\mathbf{v} = (x, y)\): \(\|\mathbf{v}\| = \sqrt{x^2 + y^2}\).
\(\sqrt{36 + 64} = \sqrt{100} = 10\).
Q4. Compute the dot product \(\begin{pmatrix} 1 \\ 3 \\ -2 \end{pmatrix}\cdot\begin{pmatrix} 4 \\ 0 \\ 5 \end{pmatrix}\).
Multiply matching components and add.
\(1\cdot4 + 3\cdot0 + (-2)\cdot5 = 4 + 0 - 10 = -6\).
Q5. The dot product of two non-zero vectors is negative. What does that tell you about the angle between them?
Recall \(\mathbf{u}\cdot\mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta\), and lengths are positive.
Since the lengths are positive, a negative dot product forces \(\cos\theta < 0\), so the angle is greater than \(90^\circ\) — the vectors point in broadly opposite directions.
Q6. Are \(\begin{pmatrix} 3 \\ 1 \end{pmatrix}\) and \(\begin{pmatrix} -1 \\ 3 \end{pmatrix}\) orthogonal?
Orthogonal iff the dot product is exactly 0.
\(3(-1) + 1\cdot3 = -3 + 3 = 0\) → yes, orthogonal (a right angle).
Q7. Two samples have profiles \(\mathbf{u}\) and \(\mathbf{v} = 5\mathbf{u}\). What is their cosine similarity, and why is that biologically reassuring?
\(\mathbf{v}\) is just \(\mathbf{u}\) scaled. Does scaling change direction?
Cosine similarity = 1. Scaling does not change direction, so two profiles that differ only by overall magnitude (e.g. sequencing depth) are correctly judged identical in shape. Cosine similarity is depth-invariant.
Q8. True or false: the dot product of two vectors is itself a vector.
Count the numbers in the result.
False. The dot product is a single scalar (one number).
Q9. Project \(\mathbf{u} = \begin{pmatrix} 5 \\ 2 \end{pmatrix}\) onto \(\mathbf{v} = \begin{pmatrix} 1 \\ 0 \end{pmatrix}\).
The shadow is \(\mathbf{p} = \dfrac{\mathbf{u}\cdot\mathbf{v}}{\mathbf{v}\cdot\mathbf{v}}\,\mathbf{v}\). Here \(\mathbf{v}\) points along the x-axis.
\(\dfrac{\mathbf{u}\cdot\mathbf{v}}{\mathbf{v}\cdot\mathbf{v}} = \dfrac{5}{1} = 5\), so the projection is \(5(1,0) = (5,\ 0)\) — the shadow on the x-axis. (Makes sense: projecting onto the x-axis just keeps the x-component.)
Q10. After projecting \(\mathbf{u}\) onto \(\mathbf{v}\), what is special about the leftover \(\mathbf{u} - \mathbf{p}\), where \(\mathbf{p}\) is the projection (the shadow)?
Think about the right angle a shadow makes with the ground.
It is orthogonal to \(\mathbf{v}\) (dot product 0). The projection captures the part of \(\mathbf{u}\) along \(\mathbf{v}\); the leftover is the part with no overlap with \(\mathbf{v}\). This is the seed of PCA and least-squares regression.
Q11. Which R expression computes the dot product of vectors u and v? (a) u * v (b) sum(u * v) (c) u %o% v
A dot product returns a single number. * is elementwise; %o% is the outer product.
sum(u * v). Option (a) gives the elementwise products (a vector), and%o%gives an outer-product matrix.u %*% valso works, returning a \(1\times1\) matrix.
Q12. A sample \(\mathbf{u}\) has cosine similarity 0 with sample \(\mathbf{v}\). Interpret this.
\(\cos\theta = 0\) means what angle?
The profiles are orthogonal (\(\theta = 90^\circ\)): as different in direction as possible without pointing opposite. The two samples share no common expression pattern in this geometric sense.