Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2.0.1 Vectors

Updated: 13 May 2026

What is a vector?

A vector can be understood in two complementary ways: as an ordered list of numbers or as a geometric object in space.

In ML, a feature vector is an ordered list of values, where each entry represents a feature of the object:

[x1x2xn]\begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix}

Each coordinate xix_i represents the value of the object for one specific feature.

Geometrically, the same vector can be interpreted as a point (or arrow) in an n-dimensional space, where each axis corresponds to one feature. In this space, the feature vector describes the object’s position based on its feature values.

Algebraic vs. geometric view of a vector.

Figure 1:Algebraic vs. geometric representation of a vector. Source: Duda (1997)

Dot product

The dot product is an operation that takes two vectors and returns a single number (a scalar). It measures how much two vectors point in the same direction.

For two vectors:

[a1a2an]and[b1b2bn]\begin{bmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \end{bmatrix} \quad \text{and} \quad \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix}

the dot product is defined as:

ab=i=1naibi\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i

or explicitly:

ab=a1b1+a2b2++anbn\mathbf{a} \cdot \mathbf{b} = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n

Orthogonality

Two vectors are orthogonal if their dot product is equal to zero. This means they are perpendicular to each other in geometric space.

For two vectors:

ab=0ab\mathbf{a} \cdot \mathbf{b} = 0 \quad \Rightarrow \quad \mathbf{a} \perp \mathbf{b}

Projection

Projection describes how much of one vector lies in the direction of another vector. Geometrically, it can be seen as the “shadow” of a vector when it is projected onto another vector.

There are two related forms of projection: scalar projection and vector projection. The scalar projection is derived from the vector projection and represents only the length of the projection. The vector projection, on the other hand, gives the full projected vector, including both direction and magnitude.

The scalar projection of a onto b is:

s=acos(θ)=abbs = \|\mathbf{a}\| \cos(\theta) = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|}

The vector projection of a onto b is:

projb(a)=acos(θ)bb=abb2b\text{proj}_{\mathbf{b}}(\mathbf{a}) = \|\mathbf{a}\| \cos(\theta)\,\frac{\mathbf{b}}{\|\mathbf{b}\|} = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2} \mathbf{b}
Vector projection

Figure 2:Projection of vector a onto vector b. Source: Wikipedia (2025)

References
  1. Duda, R. O. (1997). Pattern Recognition for HCI. Princeton University Archive. https://www.cs.princeton.edu/courses/archive/fall08/cos436/Duda/PR_model/f_vecs.htm
  2. Wikipedia. (2025). Scalar projection. Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/w/index.php?title=Scalar_projection&oldid=1280429209