skip to content

Span, Basis and Nullspace

Linear independence, the span of a set of columns, choosing a basis, and the null space of vectors a matrix sends to zero, tied together by the rank-nullity theorem. Collinear features live here.

on this pageshow

questions

5

In a feature matrix, what does it mean for the columns to be linearly dependent?

level: juniorimportance: must knowfreq 60%

answer

  1. does a column add a new direction
  2. non-trivial weights that vanish
  3. one column lies in the others' span
  4. a total column equals its parts
  5. rank drops below the column count

basics

~20 s

Linearly dependent columns means one column equals a weighted combination of the others, adding no new direction. A table holding hours_weekday, hours_weekend and their exact total is the classic case; that matrix is rank deficient.

solid answer

~40 s

Columns are linearly independent when the only weights c1, ..., cn making c1*a1 + ... + cn*an equal the zero vector are all zero. If some non-trivial choice of weights hits zero, the columns are linearly dependent: at least one of them lies in the span of the others and contributes no new direction. Concretely, if a table has `hours_weekday`, `hours_weekend` and `hours_total = hours_weekday + hours_weekend`, then 1*weekday + 1*weekend - 1*total = 0 with non-zero weights, so the three columns span only a two-dimensional space. The rank of that matrix - the number of independent columns - is 2, not 3, and the redundancy shows up as the nullspace vector (1, 1, -1). Dependence is an exact algebraic identity, not a statement that columns look similar or correlate strongly.

go deeper

for a junior

Be ready to state the zero-combination test for independence and to give a concrete dependent example, such as a total column that is the exact sum of its parts.

for a middle

Explain that dependence means the rank is below the column count and that the redundancy is recorded as a non-zero vector in the nullspace naming the exact combination.

for a senior

Show you can trace a dependent column back to how the dataset was built - derived totals, shares that complete to one, unit conversions - before it reaches anything downstream.

for a principal

Own the upstream call: whether the feature contract forbids derived duplicates at ingestion, or whether pipelines are expected to detect and drop them automatically.

## The definition Take a matrix and call its columns a1, a2, ..., an, each a vector with m entries. The columns are **linearly independent** if the equation ``` c1*a1 + c2*a2 + ... + cn*an = 0 ``` has only the trivial solution c1 = c2 = ... = cn = 0. If any choice of weights that are *not all zero* produces the zero vector, the columns are **linearly dependent**. That equation is just `Ac = 0` written out, where c is the vector of weights. So the columns are dependent exactly when the matrix has a non-zero vector in its nullspace, and independent exactly when the nullspace contains only the zero vector. ## What dependence means in words If the columns are dependent, you can solve for one of them in terms of the rest. Suppose c3 is non-zero in a vanishing combination; divide through and you get a3 written as a weighted sum of the other columns. In other words, a3 already lies in the **span** of the others - the set of all their weighted combinations. It points in no direction the others could not already reach, so removing it does not shrink the space the columns can build. This is why dependence is often phrased as redundancy. The columns still contain the same *numbers*, but they contain no extra *directions*. ## The worked example A usage table records `hours_weekday`, `hours_weekend`, and a convenience column `hours_total` defined during ingestion as the sum of the first two. Every row satisfies ``` hours_weekday + hours_weekend - hours_total = 0 ``` which is precisely a vanishing combination with weights (1, 1, -1). No matter how many rows the table has, and no matter how varied the numbers are, that identity holds row by row, so the three columns can never be independent. The three of them span a plane, not a three-dimensional space, and the matrix has rank 2 with a one-dimensional nullspace spanned by (1, 1, -1). Notice what did the damage: not the data, but the *definition* of a column. Exact dependence in real datasets almost always comes from a derived column - a total, a percentage that completes to 100, a difference of two other columns, a unit conversion. ## Rank, span and dimension The **span** of a set of columns is every vector you can build as a weighted combination of them. The **rank** of the matrix is the dimension of that span - the number of genuinely independent directions among the columns. If a matrix has n columns and rank r, then r <= n, with equality exactly when the columns are independent. A matrix whose rank is smaller than its column count is called **rank deficient** or **column rank deficient**. An important consequence: a set of dependent columns can be trimmed to an independent subset that spans exactly the same space. Any such minimal spanning subset is a **basis** of the column space, and every basis of that space has the same size, namely the rank. ## Two common traps **Dependence does not require proportionality.** Columns (1, 0), (0, 1) and (1, 1) are dependent, since the third is the sum of the first two, yet no single column is a multiple of any other. Dependence can involve three, four or all of the columns at once. **Dependence is not correlation.** Correlation is a statistical measure of how two centred columns co-vary, and it takes values across a continuous range. Dependence is a yes/no algebraic fact. Two columns correlated at 0.99 are still independent; two columns tied by an exact identity are dependent regardless of what any summary statistic says. ## Why interviewers ask it Linear dependence is the concept behind rank, the nullspace, and the whole question of whether a linear system pins down a unique answer. Candidates who can state the zero-combination test, name the redundancy it implies, and point at a realistic way a dataset acquires a dependent column have the foundation the rest of the topic builds on.

  • How would you detect that a matrix has dependent columns when you do not know which ones they are?
    Compute the rank and compare it with the number of columns; if the rank is smaller, at least one column is redundant. Elimination reveals which columns carry pivots and which do not, and any non-zero vector in the nullspace spells out the exact combination of columns that cancels, naming the culprits directly.
  • Does a dependent set of columns always contain a column that is a multiple of another?
    No. Dependence only requires some non-trivial weighted combination to vanish, and that combination may involve three or more columns. The columns (1, 0), (0, 1) and (1, 1) are dependent because the third equals the sum of the first two, yet no one of them is a scalar multiple of another.
  • If a matrix has more columns than rows, can its columns ever be independent?
    No. The rank cannot exceed the number of rows, so with n columns and m rows where n is greater than m, at most m columns can be independent. A wide matrix therefore always has a non-trivial nullspace and always has dependent columns, whatever the values in it.

Three shopping lists where the third is just the first two stapled together: reading it tells you nothing the first two did not already say.

saying these in an interview costs you the question

  • Says dependent just means the columns are highly correlated
  • Thinks dependence requires one column to be a multiple of another
  • Believes more columns always means more information
  • Claims dependence can be ruled out by inspecting column means

context

open as a page

What does the rank-nullity theorem give for a 5x3 matrix of rank 2?

level: middleimportance: must knowfreq 55%

basics

~20 s

Rank-nullity says rank plus nullity equals the number of columns. A 5x3 matrix of rank 2 therefore has nullity 3 - 2 = 1: the vectors it sends to zero form a line through the origin in three-dimensional space.

open as a page

Two feature columns correlate at 0.999 - is that matrix rank deficient?

level: seniorimportance: should knowfreq 38%

basics

~20 s

No. A correlation of 0.999 is not an exact linear identity, so the two columns stay independent and the matrix is full rank. It sits a hair from rank deficiency, so arithmetic on it behaves almost as badly.

open as a page

For a 3x3 matrix whose columns span only a plane, what does its nullspace say about solutions of Ax = b?

level: seniorimportance: should knowfreq 42%

basics

~20 s

A 3x3 matrix whose columns span only a plane has rank 2 and a one-dimensional nullspace. If b lies in that plane, solutions form a line: one particular solution plus any multiple of the nullspace vector. Otherwise none exist.

open as a page

Why does one vector in R^2 have different coordinates in the standard basis and a rotated basis?

level: middleimportance: nice to knowfreq 32%

basics

~20 s

Coordinates are the weights that rebuild a vector from a chosen basis, so they belong to the basis, not to the vector. Rotate the basis and the arrow is unchanged while the list of weights describing it changes.

open as a page