Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 2

Matrix Rank and Linear Independence

Recommended resources

In our previous lesson, we refreshed the mechanics of matrix multiplication and calculating determinants. Now, we'll shift from the "how" to the "what it means." This lesson focuses on a crucial conceptual question for your interview: "How do you determine the rank of a matrix?" The key to answering this well lies in understanding the relationship between matrix rank and the concept of linear independence.

Our goal is to equip you with a clear, intuitive explanation of what rank signifies. Think of it as uncovering the "true" number of dimensions or the amount of non-redundant information a matrix contains. This idea is fundamental in AI, especially for tasks like dimensionality reduction where we aim to simplify complex data without losing its essential structure.

From Redundancy to Independence

Imagine you have two vectors in a 2D plane. If they point in different directions, you can combine them (by scaling and adding) to reach any point in the entire plane. They are "independent." However, if they both lie on the same line (i.e., one is just a scaled version of the other), you are stuck on that line. The second vector is "redundant"; it offers no new directional information. This is the core intuition behind linear dependence.

A set of vectors is linearly dependent if at least one vector in the set can be created by a linear combination of the others. It's redundant.

Conversely, a set of vectors is linearly independent if no vector in the set can be written as a combination of the others. Each vector contributes a unique direction.

Formally, we say a set of vectors is linearly dependent if we can find a set of scalars , which are not all zero, that satisfies this equation:

If the only way to satisfy this equation is for all scalars to be zero (the "trivial solution"), then the vectors are linearly independent.

The following guide provides a concise summary of these definitions. Pay close attention to the formal definitions and the key properties.

Linear Dependence of Vectors: The Complete Guide to Understanding Vector Relationships in Machine Learning - mlforbeginners.com

This guide from mlforbeginners.com clearly defines linear dependence and independence.

Please read the sections What is Linear Dependence?, Understanding Linear Independence, and the two Formal Definitions. Focus on the core idea of "redundancy" versus "unique directional information."

Let's look at a visual representation to solidify this.

In this 3D space, vectors \(\vec{v}_1\) and \(\vec{v}_2\) span the orange plane. Any vector in that plane can be created by combining \(\vec{v}_1\) and \(\vec{v}_2\). Since vector \(\vec{v}_3\) lies within this plane, it is linearly dependent on \(\vec{v}_1\) and \(\vec{v}_2\). The set {\(\vec{v}_1, \vec{v}_2, \vec{v}_3\)} is therefore linearly dependent; these three vectors only span a 2D subspace.

The Column Space: Where a Matrix Sends Vectors

A matrix acts as a linear transformation, moving vectors from one space to another. The columns of a matrix are particularly important because they tell us where the standard basis vectors (like and ) land after the transformation.

The column space of a matrix is the set of all possible output vectors. It's the "span" of the matrix's columns—all the places you can get to by taking linear combinations of those columns.

The dimensionality of this output space is what we're interested in. Does the transformation preserve the original number of dimensions, or does it "squash" space into something smaller?

Panel A shows the standard basis vectors \(\mathbf{e}_1\) and \(\mathbf{e}_2\) in a 2D grid. Panel B shows where a transformation \(f\) sends them. The column space is the span of the new vectors, \(f(\mathbf{e}_1)\) and \(f(\mathbf{e}_2)\). If \(f(\mathbf{e}_1)\) and \(f(\mathbf{e}_2)\) are linearly independent, they still span the full 2D plane (which is just sheared). If they become collinear (linearly dependent), the entire plane is squashed onto a single line.

The brilliant 3Blue1Brown video series, Essence of linear algebra, provides the best geometric intuition for this.

Inverse matrices, column space and null space | Chapter 7, Essence of linear algebra

This video from the 3Blue1Brown channel explains the concepts of rank and column space geometrically.

Watch the segment from "zero determinant" to the end. Focus on the definition of rank as "the number of dimensions in the output of a transformation" and how the column space is the span of the columns of the matrix.


Defining Matrix Rank

We can now combine these ideas into a clear definition for your interview.

The rank of a matrix is the number of linearly independent columns it has. This number is also equal to the dimension of its column space.

A matrix is called "full rank" if its rank is equal to the number of columns. If the rank is less than the number of columns, it's "rank-deficient." This means there is redundancy in the columns—they are linearly dependent, and the transformation squashes space into a lower dimension.

The following text formalizes this definition.

22.1. Geometry and Linear Algebraic Operations

This section from the online book Dive into Deep Learning formally defines rank.

Read the section titled Rank. It connects the idea of linear dependence to the compression of space and gives a formal definition of rank as the largest number of linearly independent columns.

To build a practical, verbal explanation, it's helpful to think of checking for rank column by column. The following video provides an excellent intuitive method.

Rank of a Matrix : Data Science Basics

This video from the channel ritvikmath offers a simple, procedural way to think about rank.

Watch the first part of the video, from the start of the explanation until just before he introduces the large matrix example. The key question to internalize is: "Is this column a linear combination of any of the vectors that came before it?" The number of "no" answers is the rank.

The Link to Determinants

In our last lesson, you practiced calculating the determinant of a 2x2 matrix. Now we can connect that to rank. For a square matrix:

  • Non-zero determinant: The transformation does not collapse space to a lower dimension. The columns are linearly independent, and the matrix is full rank.
  • Zero determinant: The transformation collapses space. The columns are linearly dependent, and the matrix is rank-deficient.

This is a crucial shortcut. If an interviewer gives you a 2x2 matrix and asks for its rank, you can quickly calculate the determinant. If it's non-zero, the rank is 2. If it's zero (and the matrix isn't the zero matrix), the rank is 1.

The comparison table in the mlforbeginners.com article you reviewed earlier summarizes this relationship nicely.


How to Explain This in an Interview

If asked, "How do you determine the rank of a matrix?" you can structure your answer like this:

  1. High-level Definition: "The rank of a matrix is the number of linearly independent columns in that matrix."
  2. Geometric Intuition: "Geometrically, it tells you the number of dimensions of the output space after the matrix transforms space. For example, a 3x3 matrix with rank 2 takes 3D space and squashes it down to a 2D plane. The set of all possible outputs is called the column space, so the rank is the dimension of the column space."
  3. Connection to Redundancy: "A rank that is less than the number of columns implies there is redundancy in the data. Some columns can be expressed as combinations of others."
  4. Practical Check (for square matrices): "For a square matrix, a quick way to check if it's full rank is to calculate its determinant. A non-zero determinant means the columns are linearly independent, and the matrix is full rank."

Conclusion

This lesson has focused on the conceptual underpinnings of matrix rank, a far more critical topic for an AI interview than procedural calculations.

Key Takeaways:

  • Linear Independence: A set of vectors is linearly independent if none can be formed from a combination of the others. They are all essential and point in unique directions.
  • Column Space: This is the set of all possible outputs of a matrix transformation, formed by the span of its column vectors.
  • Matrix Rank: The rank is the number of linearly independent columns, which is equal to the dimension of the column space.
  • Rank and Determinant: For a square matrix, a rank less than the number of columns corresponds to a determinant of zero.

In our next lesson, we will explore another fundamental concept: eigenvalues and eigenvectors. We'll investigate what happens when a matrix transformation acts on a vector, but doesn't change its direction—it only scales it. This is a powerful idea with direct applications in many machine learning algorithms, including Principal Component Analysis (PCA).